AutoIt
#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <StaticConstants.au3> #include <GUIConstants.au3> ; Global Const $AC_SRC_ALPHA = 1 ; Load PNG file as GDI bitmap _GDIPlus_Startup() $pngSrc = @scriptdir&"\Torus.png" $hImage = _GDIPlus_ImageLoadFromFile($pngSrc) ; Extract image width and height from PNG $width = _GDIPlus_ImageGetWidth ($hImage) $height = _GDIPlus_ImageGetHeight($hImage) ; Create layered window $GUI = GUICreate("test", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED) SetBitMap($GUI, $hImage, 0) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() WinSetOnTop($gui,"",1) SetBitMap($GUI, $hImage, 255) AutoItSetOption ( "GUIOnEventMode", 1) $ExitButton = GUICtrlCreateLabel("x", 80, 10, 30, 30, $SS_NOTIFY + $SS_CENTER) GUICtrlSetFont(-1, 18, 800) GUICtrlSetColor(-1, 0x000000) ; why doesn't X show? ????????????? GUICtrlSetTip(-1, " Close ") GUICtrlSetOnEvent($ExitButton, "Terminate") GUISetState(@SW_SHOW) ; And what was the following for? ... since it doesn't appear to be needed. ?????????????? ;$controlGui = GUICreate("ControlGUI", $width, $height, 0,0,$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui) ;GUICtrlCreatePic(-1,0,0,$width,$height) ;GuiCtrlSetState(-1,$GUI_DISABLE) GUISetState() While 1 Sleep(500) WEnd Func Terminate() _WinAPI_DeleteObject($hImage) _GDIPlus_Shutdown() Exit EndFunc ; =============================================================================================================================== ; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image. ; =============================================================================================================================== Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) if ($hWnd = $GUI) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION EndFunc ; =============================================================================================================================== ; SetBitMap ; =============================================================================================================================== Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize ) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha" , $iOpacity ) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC (0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC ($hMemDC) EndFunc
The script is based on segments of the PNG as GUI example posted in 2007 by lod3n
Thanks in advance for any help with this.




