Jump to content
Sign in to follow this  
ViliamJobko

Transparency of of checkbox, label and radio in GUI window

Recommended Posts

ViliamJobko

Hello,

I would like to make a GUI window with background image and controls with transparent background. So I:

1. Create GUI

2. Make background with GUICtrlCreatePic("imgbg3.bmp", 0, 0, 400, 300, $SS_BITMAP)

3. Create Controls (one checkbox, one label and one radio)

4. Set GUICtrlSetBkColor($handle, $GUI_BKCOLOR_TRANSPARENT) to Controls.

Result is in screenshot (Win7, Aero theme). It simply works only for label, but according to Help File, it should work for checkbox and radio also. Is this a bug or what am I doing wrong? (Source code is in attachment)

background.au3

post-60368-0-39963800-1330115543_thumb.j

Edited by ViliamJobko

Share this post


Link to post
Share on other sites
BrewManNH

Try adding this line below the control you want it to affect.

DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", -1, "wstr", 0, "wstr", 0) ; <<<<< You may have to change the -1 to the variable you assign to the control.

You will need to add this line after every control you want it to affect, or you could turn off theming for the whole GUI using this line at the top of the script. Experiment and see which works best for you.

DllCall("UxTheme.dll", "none", "SetThemeAppProperties", "int", 0)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
UEZ

Look here:

Maybe you can extend it...

Br,

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
ViliamJobko

Thank you for answer :)

First way doesn't work at all.

The second one works well, but is there any way to bring the title bar's style back?

Meanwhile I'm going to check UEZ's link. Thanks.

EDIT: I checked UEZ's link and I make a function according to that. Maybe somebody will need it, so here it is:

Func _CreateTransparentCheckbox($sText, $iLeft, $iTop)
Local $hReturn[2]
$hReturn[0] = GUICtrlCreateCheckbox($sText, $iLeft, $iTop, 13, 13)
$hReturn[1] = GUICtrlCreateLabel($sText, $iLeft + 16, $iTop)
GUICtrlSetBkColor(-1, -2)
Return $hReturn
EndFunc

Thank both to suggestions ;)

Anyway, is there any solution for groups and radios?

Edited by ViliamJobko

Share this post


Link to post
Share on other sites
AdmiralAlkex

The first way is fine, but note that the GUICtrlCreate* functions return a control id when SetWindowTheme takes a handle. You just need to add a GUICtrlGetHandle() somewhere.

Example:

$chk = GUICtrlCreateCheckbox("This is checkbox - Lorem ipsum dolor sit amet.", 20, 20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)
$lbl = GUICtrlCreateLabel("This is label - Lorem ipsum dolor sit amet", 20, 100)
$rdo = GUICtrlCreateRadio("This is radio - Lorem ipsum dolor sit amet", 20, 180)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle(-1), "wstr", 0, "wstr", 0)

Share this post


Link to post
Share on other sites
martin

To make any controls tranparent you could do the following if you were prepared to put some work into it and to accept that there might be some delay while the effect is created.

Make the main window with your picture as the background but no components.

Create a child window with the style $WS_CHILD only which fills the main window client area and place your components on this child.

Create a window region which is the whole of the area of the child which is the default background colour and set that region so that it isn't painted. Then I think the components will be transparent.


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

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  

×