Jump to content

Recommended Posts

Posted

Was wondering if there's a way to allow a GUI window to be transparent, but have the controls in the GUI not transparent?

  Reveal hidden contents

 

Posted (edited)

Create a GUI that is transparent and then create a child GUI to the first. You will find plenty of examples in the Forum.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

To add, search using _WinAPI_SetLayeredWindowAttributes.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

Mechaflash,

Not that difficult: ;)

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

$hGUI = GUICreate("", 100, 100, -1, -1, $WS_POPUP, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))

; Must be within GUI window
$cButton_Exit = GUICtrlCreateButton(" Exit ", 10, 10, 80, 30)
$cVol_Up = GUICtrlCreateButton("Vol Up",   10, 40, 80, 30)
$cVol_Dn = GUICtrlCreateButton("Vol Down", 10, 70, 80, 30)

GUISetControlsVisible($hGUI)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $cVol_Up
            ConsoleWrite("Up" & @CRLF)
        Case $cVol_Dn
            ConsoleWrite("Down" & @CRLF)
        Case $cButton_Exit
            Exit
    EndSwitch
WEnd

Func GUISetControlsVisible($hWnd)
    Local $aM_Mask, $aCtrlPos, $aMask

    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1))

    For $i = 3 To $aLastID[0]
        $aCtrlPos = ControlGetPos($hWnd, '', $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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 10/1/2012 at 2:23 PM, 'Melba23 said:

Mechaflash,

Not that difficult: ;)

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

$hGUI = GUICreate("", 100, 100, -1, -1, $WS_POPUP, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))

; Must be within GUI window
$cButton_Exit = GUICtrlCreateButton(" Exit ", 10, 10, 80, 30)
$cVol_Up = GUICtrlCreateButton("Vol Up",   10, 40, 80, 30)
$cVol_Dn = GUICtrlCreateButton("Vol Down", 10, 70, 80, 30)

GUISetControlsVisible($hGUI)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $cVol_Up
            ConsoleWrite("Up" & @CRLF)
        Case $cVol_Dn
            ConsoleWrite("Down" & @CRLF)
        Case $cButton_Exit
            Exit
    EndSwitch
WEnd

Func GUISetControlsVisible($hWnd)
    Local $aM_Mask, $aCtrlPos, $aMask

    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1))

    For $i = 3 To $aLastID[0]
        $aCtrlPos = ControlGetPos($hWnd, '', $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

M23

Certainly a different approach that I haven't seen.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted

guinness,

Not mine - but the saved snippet does not have the author's name. So if anyone wants to claim it.....(with proof of course!). :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

  On 10/1/2012 at 2:43 PM, 'Melba23 said:

guinness,

Not mine - but the saved snippet does not have the author's name. So if anyone wants to claim it.....(with proof of course!). :)

M23

I won't take credit, but I decided to use WinAPI.au3 instead as it looks less frightening to some.

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate('', 100, 100, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))

    Local $iExit = GUICtrlCreateButton(' Exit ', 10, 10, 80, 30)
    Local $iUp = GUICtrlCreateButton('Vol Up', 10, 40, 80, 30)
    Local $iDown = GUICtrlCreateButton('Vol Down', 10, 70, 80, 30)

    GUISetControlsVisible($hGUI)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $iUp
                ConsoleWrite('Up' & @CRLF)
            Case $iDown
                ConsoleWrite('Down' & @CRLF)
            Case $iExit
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func GUISetControlsVisible($hWnd) ; By Melba23.
    Local $aControlGetPos = 0, $hCreateRect = 0, $hRectRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    Local $iLastControlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle(-1))

    For $i = 3 To $iLastControlID
        $aControlGetPos = ControlGetPos($hWnd, '', $i)
        If IsArray($aControlGetPos) = 0 Then ContinueLoop
        $hCreateRect = _WinAPI_CreateRectRgn($aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[0] + $aControlGetPos[2], $aControlGetPos[1] + $aControlGetPos[3])
        _WinAPI_CombineRgn($hRectRgn, $hCreateRect, $hRectRgn, 2)
        _WinAPI_DeleteObject($hCreateRect)
    Next
    _WinAPI_SetWindowRgn($hWnd, $hRectRgn, True)
    _WinAPI_DeleteObject($hRectRgn)
EndFunc   ;==>GUISetControlsVisible
Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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...