Sign in to follow this  
Followers 0
johnjamie

[SOLVED] Transparent control problem

13 posts in this topic

#1 ·  Posted (edited)

Hi,

I am interested in using a transparent controls function that someone has kindly made but it makes the label which I have on top of the control unclickable in the main gui.

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

My basic code says create the form, create the pic, make that pic transparent, then create the label.

$labelpic[$j][$i]=GUICtrlCreatepic($imagepath&"pictfilename.bmp", ($i-1)*$cellwidth+$offleft1, ($j-1)*$cellheight+$offsettop1, $cellwidth, $cellheight)

    $frm=_GuiCtrlMakeTrans($labelpic[$j][$i],$pictrans)

If I remove the codeline _guictrlmaketrans, the pic underlying the label isn't transparent however the label on top clicks properly.

Yet when I include that line, the transparent label becomes unclickable, but the underlying pic is transparent which I wanted.

The program works fine with the clicking and showing underlying pic part, its simply that if I want transparent underlying pics and use that above function, the transparent label over that pic won't click.

My program is like a panel, so if the label is slightly offset with the underlying pic, you can mouse over and click it and it clicks in that tiny bit of missing overlap.

I seem to have this problem with this function frequently, I have had to remove the code a few times now because it wouldn't click, however I think the function may not be returning to the actual parent handle? Not sure.

As I said, the program works fine, except when I include the above function, the label becomes unclickable.

Is there now a included Autoit function with transparent controls? Maybe I don't have to use this function.

Thanks,

John

Edited by johnjamie

Share this post


Link to post
Share on other sites



Can you show a sample script which reproduces the problem? If so please include some pic we can use.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If You want to prevent the pic control recive clicks:

maybe you should disable the pic, that prevents from recive the clicks... also you can try to add the $WS_EX_TRANSPARENT style to the pic..

I recomend try the first method add under that line

GuiCtrlSetState(-1, $GUI_DISABLE)

and remember add the include file GUIConstantsEx.au3 to the script where $GUI_DISABLE is declared.

EDITED: Added some code.

$image = @ScriptDir & "\test.jpg"
If Not FileExists($image) Then InetGet("http://i273.photobucket.com/albums/jj239/StarcraftImages/MCR.jpg", $image)
$hGui = GUICreate("test", -1, -1)
$button = GUICtrlCreateButton("test button", 15, 15, 150, 50)
_GuiCtrlMakeTrans($button, 190)
GUICtrlCreatePic($image, 0, 0, 600, 400)
GUISetState()
Do
    $msg = GUIGetMsg()
    If $msg = $button Then ConsoleWrite("click" & @CRLF)
Until $msg = -3

Func _GuiCtrlMakeTrans($iCtrlID, $iTrans = 255)

    Global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 Then Return SetError(1, 1, 0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 Then Return SetError(1, 2, 0)
    $aPos = ControlGetPos($pHwnd[0], "", $hWnd);Get the current pos of the control
    If @error Then Return SetError(1, 3, 0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 Then Return SetError(1, 4, 0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 Then Return SetError(1, 5, 0)
    If Not ControlMove($nHwnd, '', $hWnd, 0, 0) Then Return SetError(1, 6, -1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_SHOW, $nHwnd);show the new child gui

    WinSetTrans($nHwnd, "", $iTrans);set the transparency
    If @error Then Return SetError(1, 7, 0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc   ;==>_GuiCtrlMakeTrans
Edited by monoscout999

Share this post


Link to post
Share on other sites

Hi,

Thanks for quick reply.

Here is the basic part of the code.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#Include <GUIImageList.au3>
#Include <GUIButton.au3>
#Include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#Include <Crypt.au3>
#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>

HotKeySet("{END}","Quit")

Func Quit()
    Exit
EndFunc

maingui()

func maingui()

global $Form1 = GUICreate("test", 100,100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$pic=GUICtrlCreatePic("c:\guibackgroundimage.bmp",  0,0,0,0)

GUICtrlSetState($pic, $GUI_DISABLE)

   $labelpic=GUICtrlCreatepic("c:\gr2.bmp", 10, 10, 40, 40)

    $frm=_GuiCtrlMakeTrans($labelpic,150)

GUICtrlSetState($labelpic, $GUI_DISABLE)

    $labelname=GUICtrlCreatelabel("testtext", 10, 10, 40, 40, BitOr($SS_CENTER,$BS_CENTER),"")

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip($labelname, "test tooltip")

GUISwitch($form1)
;switch back to the parent Gui
GUISetState(@SW_SHOW,$form1)

EndFunc

While 1

    WEnd

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Although the label text doesn't currently show, that isn't my problem. If the .bmp file isn't present, you can see the text on the label.

If you run this program, you will see the overlying label isn't clickable.

I have disabled the pic and the background pic on the gui, so unsure.

Thanks,

John

gr2.bmp

Share this post


Link to post
Share on other sites

Maybe just use the same function (make transparent) on the label and move it above the pic?

If that ruins the transparency effect you want., you could make a child widow for the label and set a window region to remove everything exccept the text and then the text would be printed without any transparency on top of your pic. You could still control the transparency if you wanted of course.

; Author: johnjamie
; Topic Title: Transparent control problem - AutoIt Forums
; Post URL: http://www.autoitscript.com/forum/topic/131204-transparent-control-problem/page__view__findpost__p__913396

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#include <GUIImageList.au3>
#include <GUIButton.au3>
#include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include <Crypt.au3>
;#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>

#include <constants.au3>;<-----added

Global $labelname
HotKeySet("{END}", "Quit")

Func Quit()
    Exit
EndFunc   ;==>Quit

maingui()

Func maingui()

    Global $Form1 = GUICreate("test", 100, 100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
GUISetBkColor(0xffff00)
    $pic = GUICtrlCreatePic("c:\guibackgroundimage.bmp", 0, 0, 0, 0)

    GUICtrlSetState($pic, $GUI_DISABLE)

    $labelpic = GUICtrlCreatePic("gr2.bmp", 10, 10, 40, 40)
    GUICtrlSetState(-1,$GUI_DISABLE)

    $frm = _GuiCtrlMakeTrans($labelpic, 150)

    GUICtrlSetState($labelpic, $GUI_DISABLE)


    $labelname=GUICtrlCreatelabel("testtext", 10, 10, 40, 40, BitOr($SS_CENTER,$BS_CENTER),"")

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip($labelname, "test tooltip")

    $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE)
    _WinAPI_SetWindowPos(_GuiCtrlMakeTrans($labelname, 80), $HWND_TOP, 0, 0, 0, 0, $iFlags);$HWND_TOP

    GUISwitch($Form1)
    ;switch back to the parent Gui
    GUISetState(@SW_SHOW, $Form1)

EndFunc   ;==>maingui

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        case $labelname
            ConsoleWrite("clicked" & @CRLF)
    EndSwitch

WEnd

Func _GuiCtrlMakeTrans($iCtrlID, $iTrans = 255)

    Global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 Then Return SetError(1, 1, 0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 Then Return SetError(1, 2, 0)
    $aPos = ControlGetPos($pHwnd[0], "", $hWnd);Get the current pos of the control
    If @error Then Return SetError(1, 3, 0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1],0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 Then Return SetError(1, 4, 0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 Then Return SetError(1, 5, 0)
    If Not ControlMove($nHwnd, '', $hWnd, 0, 0) Then Return SetError(1, 6, -1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_SHOW, $nHwnd);show the new child gui
   ; $labelname = GUICtrlCreateLabel("testtext", 10, 10, 40, 40, BitOR($SS_CENTER, $BS_CENTER), "")
    WinSetTrans($nHwnd, "", $iTrans);set the transparency
    If @error Then Return SetError(1, 7, 0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc   ;==>_GuiCtrlMakeTrans

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Hi Martin,

I understand what you said about child window and strip all but text, however I wouldn't know how to do it.

Secondly, I'm fairly sure it should be easier to do, as I've found if the underlying pic which is transparented and the overlaying label are slightly offset, you can click where in the little area where there is missing overlap. The tooltip also shows in this area.

I think its fairly simply just switching to the correct layer which has the labels on it.

The code works fine in the creation order I currently have it, create underlyingpic, transparency underlying pic, create label, its simply when I use the transparency function, it introduces one or more layers and the program gets confused when it comes to clicking in that area.

If I click the tiny bit of square to the right of the pic, the "t" character, the tooltip shows as in the following screenshot.

The program is simply confused, yet I have coded it in the correct creation order, first pic then last label.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#Include <GUIImageList.au3>
#Include <GUIButton.au3>
#Include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#Include <Crypt.au3>
#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>

HotKeySet("{END}","Quit")

Func Quit()
    Exit
EndFunc

maingui()

func maingui()

global $Form1 = GUICreate("test", 100,100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$pic=GUICtrlCreatePic("c:\guibackgroundimage.bmp",  0,0,0,0)

GUICtrlSetState($pic, $GUI_DISABLE)

   $labelpic=GUICtrlCreatepic("c:\gr2.bmp", 10, 10, 40, 40)

    $frm=_GuiCtrlMakeTrans($labelpic,150)

GUICtrlSetState($labelpic, $GUI_DISABLE)

    $labelname=GUICtrlCreatelabel("testtext", 10, 10, 50, 50, BitOr($SS_CENTER,$BS_CENTER),"")

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip($labelname, "test tooltip")

GUISwitch($form1)
;switch back to the parent Gui
GUISetState(@SW_SHOW,$form1)

EndFunc

While 1

    WEnd

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Posted Image

Thanks,

John

Share this post


Link to post
Share on other sites

Since you made th elabel th esame size as the pic, why don't you just detect clicking the pic?

If you want to know how to strip all of a window apart from th etext I can make an example for you.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Since you made th elabel th esame size as the pic, why don't you just detect clicking the pic?

If you want to know how to strip all of a window apart from th etext I can make an example for you.

Hi Martin,

I could possibly detect the pic, had a brief try, it didn't work, however it still doesn't explain why its not working, re layers or something.

If I detected the pic and it did work for example, the tooltips still wouldn't show.

I may have to leave the transparency part out for the moment, the rest of the code is working fine. It's wierd, Ive tried to use this code a number of times and it works well in making controls transparent, but for me it removes the clickables and I'm having trouble working out why at the moment.

I thought about placing a new label over it all, but my order to create the gui is already pic then label, so it wouldn't do much. :)

Thanks,

John

Share this post


Link to post
Share on other sites

Hi, Ive almost worked it out.

Modifying the transparent function slightly to not set windows transparency does the trick with activating the label and having the tooltip. Now its just that it is removing the label text.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#Include <GUIImageList.au3>
#Include <GUIButton.au3>
#Include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#Include <Crypt.au3>
#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>

HotKeySet("{END}","Quit")

Func Quit()
    Exit
EndFunc

maingui()

func maingui()

global $Form1 = GUICreate("test", 100,100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$pic=GUICtrlCreatePic("c:\guibackgroundimage.bmp",  0,0,0,0)

GUICtrlSetState($pic, $GUI_DISABLE)

   $labelpic=GUICtrlCreatepic("c:\gr2.bmp", 10, 10, 40, 40)

    $frm=_GuiCtrlMakeTrans($labelpic,150)

GUICtrlSetState($labelpic, $GUI_DISABLE)

    $labelname=GUICtrlCreatelabel("testtext", 10, 10, 50, 50, BitOr($SS_CENTER,$BS_CENTER),"")

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip($labelname, "test tooltip")
_GuiCtrlMakeTrans2($labelname)
GUISwitch($form1)
;switch back to the parent Gui
GUISetState(@SW_SHOW,$form1)

EndFunc

While 1

    WEnd

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Func _GuiCtrlMakeTrans2($iCtrlID)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    ;WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Just trying to work out how to make it keep the label text, then its done.

Cheers,

John

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Ack, thought it worked, back to working on it.

It is still not working.

Conceptually this is my approach.

1) create underlying pic.

2) apply transparency function to the pic.

3) create overlaying label

4) apply another function trans2 slightly modified to the label with the transparency set line removed.

5) create another label just like step 3 overlying the first label, however don't apply the transparency function to it.

Now the underlying pic is transparent, the label tooltips, text show but no clicking.

I would apply the transparency function to the second label, however it would simply remove the text like it did previously.

The problem is something about child gui's that is causing the trouble.

Cheers,

John

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#Include <GUIImageList.au3>
#Include <GUIButton.au3>
#Include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#Include <Crypt.au3>
#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>

HotKeySet("{END}","Quit")

Func Quit()
    Exit
EndFunc

maingui()

func maingui()

global $Form1 = GUICreate("test", 100,100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$pic=GUICtrlCreatePic("c:\guibackgroundimage.bmp",  0,0,0,0)

GUICtrlSetState($pic, $GUI_DISABLE)

   $labelpic=GUICtrlCreatepic("c:\gr2.bmp", 10, 10, 40, 40)

    $frm=_GuiCtrlMakeTrans($labelpic,150)

GUICtrlSetState($labelpic, $GUI_DISABLE)

    $labelname=GUICtrlCreatelabel("testtext", 10, 10, 50, 50, BitOr($SS_CENTER,$BS_CENTER),"")

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip($labelname, "test tooltip")
_GuiCtrlMakeTrans2($labelname)
$labelname2=GUICtrlCreatelabel("testtext", 10, 10, 50, 50, BitOr($SS_CENTER,$BS_CENTER),"")
GUISwitch($form1)
;switch back to the parent Gui
GUISetState(@SW_SHOW,$form1)

EndFunc

While 1

    WEnd

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Func _GuiCtrlMakeTrans2($iCtrlID)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $labelname=GUICtrlCreatelabel("Conditions: ",30, 30, 40, 40, BitOr($SS_CENTER,$BS_CENTER))
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    ;WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc
Edited by johnjamie

Share this post


Link to post
Share on other sites

Not sure what I changed but dies this do what you want?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#Include <GUIImageList.au3>
#Include <GUIButton.au3>
#Include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#Include <Crypt.au3>
;#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>
#include <constants.au3>;<-----added
HotKeySet("{END}","Quit")

Global $labelname, $frm,$labelname2

Func Quit()
    Exit
EndFunc

maingui()

func maingui()

global $Form1 = GUICreate("test", 100,100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$pic=GUICtrlCreatePic("c:\guibackgroundimage.bmp",  0,0,0,0)

GUICtrlSetState($pic, $GUI_DISABLE)

   $labelpic=GUICtrlCreatepic("gr2.bmp", 10, 10, 40, 40)

    $frm=_GuiCtrlMakeTrans($labelpic,150)

GUICtrlSetState($labelpic, $GUI_DISABLE)

    $labelname=GUICtrlCreatelabel("testtext", 10, 10, 50, 50, BitOr($SS_CENTER,$BS_CENTER),"")

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetTip($labelname, "test tooltip")
$frm2 = _GuiCtrlMakeTrans2($labelname)
$labelname2=GUICtrlCreatelabel("testtext", 10, 10, 50, 50, BitOr($SS_CENTER,$BS_CENTER),"")

GUISwitch($form1)
;switch back to the parent Gui
GUISetState(@SW_SHOW,$form1)



EndFunc
while 1
$msg = GUIGetMsg()
if $msg= -3 then exit
if $msg = $labelname then ConsoleWrite("wwss" & @CRLF)
    WEnd

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Func _GuiCtrlMakeTrans2($iCtrlID)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    ;$nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $frm);$pHwnd[0]);greate a gui in the position of the control
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], 0,0, $WS_CHILD,-1, $frm);$pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $labelname2=GUICtrlCreatelabel("Conditions: ",4,10, 40, 40, BitOr($SS_CENTER,$BS_CENTER))
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    ;WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Hi Martin,

Its working fine, I haven't had time to reply yet as I have an interview this thursday.

I will post the working code soon, the conceptual approach above which I was talking about did work.

Thanks,

John

Share this post


Link to post
Share on other sites

Hi,

Its working.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Inet.au3>
#include <Sound.au3>
#Include <GUIImageList.au3>
#Include <GUIButton.au3>
#Include <GUIImageList.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#Include <Crypt.au3>
#include <secdelete.au3>
#include <date.au3>
#include <string.au3>
#include <GDIPlus.au3>

global $labelpic
global $labelname

HotKeySet("{END}","Quit")

Func Quit()
    Exit
EndFunc

maingui()

func maingui()

global $Form1 = GUICreate("test", 100,100, 40, 40, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))

$pic=GUICtrlCreatePic("c:\guibackgroundimage.bmp",  0,0,0,0)

GUICtrlSetState($pic, $GUI_DISABLE)

   $labelpic=GUICtrlCreatepic("c:\gr2.bmp", 10, 10, 40, 40)
GUICtrlSetState($labelpic, $GUI_DISABLE)
    $frm=_GuiCtrlMakeTrans($labelpic,150)

    GUICtrlSetBkColor($labelname, $GUI_BKCOLOR_TRANSPARENT)
$labelname=GUICtrlCreatelabel("", 10, 10, 40, 40, BitOr($SS_CENTER,$BS_CENTER),"")
_GuiCtrlMakeTrans2($labelname)
GUICtrlSetTip($labelname, "test tooltip")
$labelnameb=GUICtrlCreatelabel("testtext", 10, 10, 40, 40, BitOr($SS_CENTER,$BS_CENTER),"")
GUICtrlSetBkColor($labelnameb, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($labelnameb,0xffffff)
GUISwitch($form1)


;switch back to the parent Gui
GUISetState(@SW_SHOW,$form1)

EndFunc

While 1
 $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                MsgBox(0, "", "Dialog was closed")
                Exit
            case $msg =$labelpic
                msgbox(0,"","You clicked labelpic")
            case $msg =$labelname
                msgbox(0,"","You clicked labelname")

      EndSelect

    WEnd

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

Func _GuiCtrlMakeTrans2($iCtrlID)

    global $pHwnd, $nHwnd, $aPos, $a

    $hWnd = GUICtrlGetHandle($iCtrlID);Get the control handle
    If $hWnd = 0 then Return SetError(1,1,0)
    $pHwnd = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", $hWnd);Get the parent Gui Handle
    If $pHwnd[0] = 0 then Return SetError(1,2,0)
    $aPos = ControlGetPos($pHwnd[0],"",$hWnd);Get the current pos of the control
    If @error then Return SetError(1,3,0)
    $nHwnd = GUICreate("", $aPos[2], $aPos[3], $aPos[0], $aPos[1], 0x80000000, 0x00080000 + 0x00000040, $pHwnd[0]);greate a gui in the position of the control
    If $nHwnd = 0 then Return SetError(1,4,0)
    $a = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $hWnd, "hwnd", $nHwnd);change the parent of the control to the new gui
    If $a[0] = 0 then Return SetError(1,5,0)
    If NOT ControlMove($nHwnd,'',$hWnd,0,0) then Return SetError(1,6,-1);Move the control to 0,0 of the newly created child gui
    GUISetState(@SW_Show,$nHwnd);show the new child gui

    ;WinSetTrans($nHwnd,"",$iTrans);set the transparency
    If @error then Return SetError(1,7,0)
    GUISwitch($pHwnd[0]);switch back to the parent Gui

    Return $nHwnd;Return the handle for the new Child gui

EndFunc

http://imageshack.us/g/42/clickedq.png/

http://imageshack.us/photo/my-images/849/tooltipn.png/

It gets messy though, the tooltip is in one half and the text is in the other. If you click, you can see which part it is responding too.

Thanks,

John

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0