Danyg

Imagebutton with Transparent GUI

4 posts in this topic

I'm using an image as a button with the following code:

Local $idSearch = GUICtrlCreateButton("Search", 0, 0, 99, 22, $BS_BITMAP)
_GUICtrlButton_SetImage($idSearch, "green-button.bmp")

and a $WS_POPUP GUI with the same dimensions as the image (99x22).

The image is a rounded button, and on the edges you can see the background of the GUI and the border (See attached image).

I would prefer this to be transparent so that you can only see the button. This would perhaps require that the button uses PNG transparency?

 

Is there any way to make the GUI transparent, but the button solid, and then use a transparent PNG image as the button?

now.png

Share this post


Link to post
Share on other sites



Last time I checked a button can only take a bmp image and bmp images do not support transparency (at least, gui controls do not support transparency using bmp images)

Your best bet would be to use GDI+ to create your own button since GDI+ will support transparency. I'm not going to write the code to do this because there are literally hundreds of topics on GDI+ but what you're looking for is you'll need a control that can act like a button that won't actually been seen (like a blank label or a pic), create a graphic, load your image, draw the image onto the graphic in the same coordinates as your control. When the user clicks the pic, they're actually clicking the underlying control, thus activating whatever you want your button to do.

Share this post


Link to post
Share on other sites

Before I dive into the GDI+ route can this be done with a GuiCtrlCreatePic instead? I have the exact same scenario as the OP except with GuiCtrlCreatePic.

$GUI_Resume_Zoom = GUICreate("Resume Zoom", 35, 35, 555, -78, $WS_POPUP, BitAND($WS_EX_TRANSPARENT, $WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST), $GUI_GOOGLE_MAIN)
            GUICtrlCreatePic($AppPathImages & "\FocusOff.gif", 0, 0, 35, 35)
                GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
                GUICtrlSetOnEvent(-1, "_AutoZoom_Resume")
            GUISetState()

 

 

Share this post


Link to post
Share on other sites

Figured it out,

$GUI_Resume_Zoom = GUICreate("Resume Zoom", 35, 35, 555, -78, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED), $GUI_GOOGLE_MAIN)
                GUISetBkColor(0xFFFFFF)

            GUICtrlCreatePic($AppPathImages & "\FocusOff.gif", 0, 0, 35, 35)
                GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
                GUICtrlSetOnEvent(-1, "_AutoZoom_Resume")

            _WinAPI_SetLayeredWindowAttributes($GUI_Resume_Zoom, 0xFFFFFF, 255)
            GUISetState()

 

 

1 person likes this

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