Jump to content

Transparent PNG forms?


AgentSmith15
 Share

Recommended Posts

I have searched throught the forums for "transparent + png" and havn't found what I am looking for. I'm trying to use a transparent PNG as a form with a hidden taskbar.

I have found that the code below to work fine with BMPs but the quality of the semi transparent areas is terrible.

#NoTrayIcon
#include <GUIConstants.au3>
opt("GUIOnEventMode", 1)

Dim $s_TempFile
$bmp = _TempFile()

FileInstall("gui.bmp", $bmp)

; Caption
$caption = "Program name..."
; Caption

$gui = GUICreate("Main GUI", 300, 440, -1, -1, $WS_POPUP + $WS_SYSMENU + $WS_MINIMIZEBOX, $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$caption = GUICtrlCreateLabel($caption, 12, 4, 180, 14)
GUICtrlSetStyle($caption, -1, $WS_EX_TRANSPARENT); To show $caption text
GUICtrlSetStyle($caption, $DS_SETFOREGROUND)
GUICtrlSetFont($caption, 9, 400, -1, "Arial Bold")
GUICtrlSetColor($caption, 0xF5F5F5)
GUICtrlSetOnEvent($caption, "_Drag")
;GUICtrlSetBkColor($caption,0xFF00FF); To select $caption
$min = GUICtrlCreateLabel("", 198, 4, 11, 11)
GUICtrlSetOnEvent($min, "Minimize")
GUICtrlSetTip($min, "Minimize")
;GUICtrlSetStyle($min, -1, $WS_EX_TRANSPARENT); To select $min
;GUICtrlSetBkColor($min,0xFF00FF); To select $min
$close = GUICtrlCreateLabel("", 210, 4, 11, 11)
GUICtrlSetOnEvent($close, "Close")
GUICtrlSetTip($close, "Close")
;GUICtrlSetStyle($close, -1, $WS_EX_TRANSPARENT); To select $close
;GUICtrlSetBkColor($close,0xFF00FF); To select $close
$pic = GUICtrlCreatePic($bmp, 0, 0, 300, 440)
GUICtrlSetOnEvent($pic, "_Drag")
$contextmenu = GUICtrlCreateContextMenu($pic)
$min_item = GUICtrlCreateMenuItem("Min", $contextmenu)
GUICtrlSetOnEvent($min_item, "Minimize")
$close_item = GUICtrlCreateMenuItem("Close", $contextmenu)
GUICtrlSetOnEvent($close_item, "Close")
GUICtrlCreateMenuItem("", $contextmenu); separator
$about_item = GUICtrlCreateMenuItem("About", $contextmenu)
GUICtrlSetOnEvent($about_item, "About")

GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
WEnd


Func About()
    GUISetState(@SW_HIDE)
    SplashTextOn("btn", "Button clicked", 130, 19, -1, -1, 1, "", 12)
    Sleep(100)
    SplashOff()
    GUISetState(@SW_SHOW)
EndFunc

Func Close()
    GUISetState(@SW_HIDE)
    FileDelete($bmp)
    Exit
EndFunc

Func Minimize()
    GUISetState(@SW_MINIMIZE)
EndFunc

Func _TempFile()
    Local $s_TempName
    
    Do
        $s_TempName = "~"
        While StringLen($s_TempName) < 7
            $s_TempName = $s_TempName & Chr(Round(Random(65, 90), 0))
        WEnd
        $s_TempName = @TempDir & "\" & $s_TempName & ".tmp"
    Until Not FileExists($s_TempName)
    Return ($s_TempName)
EndFunc

Func _Drag()
    DllCall("user32.dll", "int", "ReleaseCapture")
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $gui, "int", 0xA1, "int", 2, "int", 0)
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...