Sign in to follow this  
Followers 0
bob.frew

Image Transparency On Gui

2 posts in this topic

Hi all,

Can anyone help with this one. It is probably the way I am reading things.

Was it Henry Ford who said "You can have any colour you like as long as its black" ?

I'm using Windows XP SP2 with AutoIt V1.1.113 beta

Having dabbled with AutoIt for a while now I came back to a problem I had shelved - "transparent image on a GUI".

I have run some tests and it seems that:-

With no extended style on GUICreate

1) If your image background colour is black then the transparency works beautifully.

2) If your image background colour is NOT black then the transparency doesn't work and you see the image background.

With the extended style $WS_EX_LAYERED on GUICreate

1) If your image background colour is black then the transparency works beautifully.

2) If your image background colour is NOT black then the transparency works too well and you see what is behind the GUI window.

I tried this with several different images and different image background colours with results as above every time.

Having found a way of working I am now a happy bunny again, but is there a better way ?? or if not should the help file just say to use a black image background?

Cheers Bob (have attached code and files)

p.s. I may well have messed up the attaching bit, in which case OOPS. Merlin1 has a black background and Merlin2 a red one

#include <GUIConstants.au3>
Dim $WindowColour = 0x005757; 
Dim $pic1 = "merlin1.gif"
Dim $pic2 = "merlin2.gif"
Dim $w1, $w2
Dim $pc1, $pc2
$w1 = GUICreate("Trial without style", 400, 200, 30, 30 ) 
GUISetBkColor($WindowColour)
GUICtrlCreateLabel("Trial of transparency with different background colours", 10, 10, 380, 30)
GUICtrlSetFont(-1,12,4,"","Arial")
$pc1 = GuiCtrlCreatePic($pic1,10,60,100,100)
$pc2 = GuiCtrlCreatePic($pic2,110,60,100,100)
GUICtrlCreateLabel("This window times out in 6 seconds", 230, 60, 150, 40)
GUICtrlSetFont(-1,14,4,"","Arial")
GUISetState(@SW_SHOW, $w1)
Sleep(6000)
GUISetState(@SW_HIDE, $w1)

$w2 = GUICreate("Trial with style", 400, 200, 30, 30, -1, $WS_EX_LAYERED ) 
GUISetBkColor($WindowColour)
GUICtrlCreateLabel("Trial of transparency with different background colours", 10, 10, 380, 30)
GUICtrlSetFont(-1,12,4,"","Arial")
$pc1 = GuiCtrlCreatePic($pic1,10,60,100,100)
$pc2 = GuiCtrlCreatePic($pic2,110,60,100,100)
GUICtrlCreateLabel("This window times out in 6 seconds", 230, 60, 150, 40)
GUICtrlSetFont(-1,14,4,"","Arial")
GUISetState(@SW_SHOW, $w2)
Sleep(6000)
GUISetState(@SW_HIDE, $w2)
Exit

AutoIt is great - leave me alone and I'll play for hours

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