qwert Posted November 9, 2010 Posted November 9, 2010 This was provided as a rule of thumb in a post a couple of years ago: If you use the $WS_EX_LAYERED property and you add an image, every pixel within the entire GUI that is the same color as the top-left pixel of the LAST image added will be transparent. It's been many months since I've worked with this and I'm confounded by the result I'm getting now that I'm trying to use the technique. Here's a very simple example to demonstrate what I'm seeing (bmp is attached below): #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> $gui = GUICreate("", 800, 600, -1, -1, -1, $WS_EX_LAYERED) ; removed $WS_POPUP for this test GUISetBkColor(0x808080) $img = GUICtrlCreatePic(@ScriptDir & "\sailboat2.bmp", 0, 0, 100, 200) GUISetState(@SW_SHOW) GUISetState() While 1 Sleep ( 250 ) If _IsPressed("1B") Then MsgBox(0,"_IsPressed", "Esc Key Pressed") ExitLoop EndIf WEnd Exit The small screen capture shows the result I'm getting. Rather than the pink color being entirely transparent, only the leading edge and the bottom edge are transparent. I'm sure it's something simple that I'm missing, but after trying a dozen variations, I can't see it. I will appreciate any suggestion of what I have missed. Thanks in advance.Sailboat2.bmp
UEZ Posted November 9, 2010 Posted November 9, 2010 (edited) Try this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> $gui = GUICreate("", 84, 128, -1, -1, $WS_POPUP, $WS_EX_LAYERED) ; removed $WS_POPUP for this test GUISetBkColor(0x808080) $hLabel = GUICtrlCreateLabel("", 8, 6, 66, 111, -1, $GUI_WS_EX_PARENTDRAG) $img = GUICtrlCreatePic(@ScriptDir & "\sailboat2.bmp", 0, 0, 0, 0) GUISetState(@SW_SHOW) While 1 Sleep ( 250 ) If _IsPressed("1B") Then MsgBox(0,"_IsPressed", "Esc Key Pressed") ExitLoop EndIf WEnd Exit Transparency will only work when you set the width and height to 0 in GUICtrlCreatePic() function! Br, UEZ Edited November 9, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
qwert Posted November 9, 2010 Author Posted November 9, 2010 Transparency will only work when you set the width and height to 0 in GUICtrlCreatePic() function! Perfect! But how did you know that? The help file only says "if you want the picture to have the same size as the content, use 0's". It's not something I would have thought of ... yet if I had tried the example 2, it would have worked.Anyway, thanks for the solution. I think it will help others, as well.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now