Jump to content
Deye

Setting a transparent gui

Recommended Posts

Deye

On click dragging the gui I need the second gui to be transparent showing only its border 
i thought I had it worked out but only for a while it worked thus changed

 

#include <GUIConstants.au3>
#include <GuiconstantsEx.au3>
#include <Misc.au3>
#include <WinAPI.au3>

$hDLL = DllOpen("user32.dll")
OnAutoItExitRegister("On_Exit")

Global $iWidth = 360, $iHeight = 180
$hGUI = GUICreate("X", $iWidth, $iHeight, -1, -1)
GUISetBkColor(0X89A5D3, $hGUI)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", 500, "long", 0x00040010)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_close
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            OnDrag()
    EndSwitch
WEnd

Func OnDrag()
    Local $width, $height, $aCurInfo = GUIGetCursorInfo($hGUI)
    If $aCurInfo[4] = 0 Then ; Mouse not over a control
        Local $aGPos = WinGetPos($hGUI)
        Local $aMPos = MouseGetPos()
        GUISetState(@SW_HIDE, $hGUI)
        Local $hChild = GUICreate("X", $aGPos[2], $aGPos[3], $aGPos[0], $aGPos[1], BitOR($WS_EX_COMPOSITED, $WS_EX_LAYERED))
        GUISetState(@SW_SHOW, $hChild)
        GUISetBkColor(0xABCDEe)
        _WinAPI_SetLayeredWindowAttributes($hChild, 0xABCDEe, 255)

        GUISetCursor(10)
        While _IsPressed("01", $hDLL)
            Sleep(20)
            $aPos = MouseGetPos()
            $height = ($aGPos[3] / $aGPos[2]) * ($aGPos[2] + ($aMPos[1] - $aPos[1]) - ($aMPos[0] - $aPos[0]))
            If $height > @DesktopHeight - 40 Or $height <= $iHeight Then ExitLoop
            $width = ($aGPos[2] / $aGPos[3]) * $height
            WinMove($hChild, "", ($aGPos[2] / 2) + $aGPos[0] - ($width / 2), ($aGPos[3] / 2) + $aGPos[1] - ($height / 2), $width, $height)
            Sleep(20)
        WEnd
        $aGPos = WinGetPos($hChild)
        WinMove($hGUI, "", $aGPos[0], $aGPos[1], $aGPos[2], $aGPos[3])
        GUIDelete($hChild)
        GUISetState(@SW_SHOW, $hGUI)
    EndIf
EndFunc   ;==>OnDrag

Func On_Exit()
    DllClose($hDLL)
EndFunc   ;==>On_Exit

 

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

×