Jump to content

Making a GUI transparent


Recommended Posts

Hello I am looking for a way to make a GUI transparent but not the controls on it.

 

Does anyone have some advice on how to do this? I found some info pointing to using _WinAPI_UpdateLayeredWindow() but there is no example code in the help file on how to use it.

 

Func loading()
    Global $hGUI = GUICreate("", 500, 500, -1, -1, $WS_POPUP + $WS_EX_LAYERED)
    GUISetBkColor("0xFFFFFF")
    Global $hGIF = GUICtrlCreatePic("", 50, 50, 400, 400)
    _GUICtrlSetGIF($hGIF, $loading_image, Default, 1)
    GUICtrlCreateLabel("Loading.... Please Wait...", 85, 450, 400, 100)
    GUICtrlSetFont(-1, 24)
    GUISetState()
EndFunc   ;==>loading

 

Link to comment
Share on other sites

An other way...   :)

; http://www.autoitscript.com/forum/topic/157841-gui-fun/

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "QuitApp")

$Main_Gui = GUICreate("", 400, 400, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)

$But1 = GUICtrlCreateButton(" Exit ", 100, 100, 80, 21)
$But2 = GUICtrlCreateLabel(" drag me ", 250, 100, 80, 21, -1, $GUI_WS_EX_PARENTDRAG)
$Info_Edit = GUICtrlCreateEdit("A few words to start off with", 80, 150, 300, 220)

GUISetControlsVisible($Main_Gui)

GUISetState()

While 1
    If GUIGetMsg() = $But1 Then Exit
WEnd

Func GUISetControlsVisible($hWnd)
    Local $aClassList, $aM_Mask, $aCtrlPos, $aMask
    
    $aClassList = StringSplit(_WinGetClassListEx($hWnd), @LF)
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    
    For $i = 1 To UBound($aClassList) - 1
        $aCtrlPos = ControlGetPos($hWnd, '', $aClassList[$i])
        If Not IsArray($aCtrlPos) Then ContinueLoop
        
        $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _
            "long", $aCtrlPos[0], _
            "long", $aCtrlPos[1], _
            "long", $aCtrlPos[0] + $aCtrlPos[2], _
            "long", $aCtrlPos[1] + $aCtrlPos[3])
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1)
EndFunc

Func _WinGetClassListEx($sTitle)
    Local $sClassList = WinGetClassList($sTitle)
    Local $aClassList = StringSplit($sClassList, @LF)
    Local $sRetClassList = "", $sHold_List = "|"
    Local $aiInHold, $iInHold
    
    For $i = 1 To UBound($aClassList) - 1
        If $aClassList[$i] = "" Then ContinueLoop
        
        If StringRegExp($sHold_List, "\|" & $aClassList[$i] & "~(\d+)\|") Then
            $aiInHold = StringRegExp($sHold_List, ".*\|" & $aClassList[$i] & "~(\d+)\|.*", 1)
            $iInHold = Number($aiInHold[UBound($aiInHold)-1])
            
            If $iInHold = 0 Then $iInHold += 1
            
            $aClassList[$i] &= "~" & $iInHold + 1
            $sHold_List &= $aClassList[$i] & "|"
            
            $sRetClassList &= $aClassList[$i] & @LF
        Else
            $aClassList[$i] &= "~1"
            $sHold_List &= $aClassList[$i] & "|"
            $sRetClassList &= $aClassList[$i] & @LF
        EndIf
    Next
    
    Return StringReplace(StringStripWS($sRetClassList, 3), "~", "")
EndFunc

Func QuitApp()
    Exit
EndFunc

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...