Jump to content

Set Transparency on CheckBox, Input, Combo

Go to solution Solved by UEZ,

Recommended Posts

As the tittle says i wan to set transparency on a checkbox and input and a combo.
This is the picture of my gui.


I used this function to set transparency of the button but the problem is that is sets the transparency of the entyre control which means you can't see the letters inside the button.
I just set a transparent label on the button and this is how i solved the problem.

Func _GuiCtrlMakeTrans($iCtrlID,$iTrans=255)
    Local $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
However when i try it on the other items, the controlmove fails. It moves the items to other places messing up the entire gui. And i have the same problem as the Button.
Any ideas how to set transparency of these items without having to create a child gui or something else?




Link to post
Share on other sites

When Controlmove fails, just move the child gui.

There are other solutions for this problem in this forums. Just search for them.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to post
Share on other sites
  • Solution

You can try something like this here:

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiComboBox.au3>

$hGUI = GUICreate("Test", 262, 145, -1, -1)
$iPic_Bg = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Logo4.gif", 0, 0, 262, 145)
GUICtrlSetState(-1, $GUI_DISABLE)
$iLabel_Name = GUICtrlCreateLabel("Name:", 17, 19, 59, 16)
GUICtrlSetFont(-1, 8.5, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xFF0000)
$iLabel_Pwd = GUICtrlCreateLabel("Password:", 17, 62, 65, 16)
GUICtrlSetFont(-1, 8.5, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xFF0000)
$iCombo_Names = GUICtrlCreateCombo("My Name", 89, 15, 161, 22)
GUICtrlSetFont(-1, 8.5, 400, 0, "Arial")
$iInput_Pwd = GUICtrlCreateInput("Password", 89, 58, 161, 20, $ES_PASSWORD)
$iCheckbox_Voice = GUICtrlCreateCheckbox("Voice", 17, 97, 65, 20)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($iCheckbox_Voice), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
$iCheckbox_Mode = GUICtrlCreateCheckbox("Mode", 17, 117, 65, 16)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($iCheckbox_Mode), "wstr", 0, "wstr", 0)
GUICtrlSetColor(-1, 0xFFFFFF)
$iLabel_Login = GUICtrlCreateLabel("Log in", 153, 115, 42, 16)
GUICtrlSetFont(-1, 8.5, 400, 0, "Arial")
GUICtrlSetFont(-1, 8.5, 400, 0, "Arial Black")
GUICtrlSetColor(-1, 0xFFFFFF)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE



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

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...