#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
$hMain_GUI = GUICreate('Gradient Cover GUI (using GDI+)', 300, 200)
GUICtrlCreateLabel('Top Data' & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & 'Middle data' & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & @CRLF & 'Bottom Data', 20, 15, 260, 200, $SS_CENTER)
GUISetState(@SW_SHOW, $hMain_GUI)
$hCover_GUI = GUICreate('', 300, 200, -1, -1, $WS_POPUP, $WS_EX_LAYERED, $hMain_GUI)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(_GetGradientPNG())
_WinAPI_SetBitMap($hCover_GUI, $hImage, 255)
WM_MOVE($hMain_GUI, 0, 0, 0)
GUIRegisterMsg($WM_MOVE, 'WM_MOVE')
GUIRegisterMsg($WM_ACTIVATE, 'WM_ACTIVATE')
GUISetState(@SW_SHOWNOACTIVATE, $hCover_GUI)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Exit
EndSwitch
WEnd
Func _GetGradientPNG($sPNG_File = '')
If $sPNG_File = '' Or Not FileExists($sPNG_File) Then
$sPNG_File = @TempDir & '\Gradient.png'
EndIf
Local $hFile = FileOpen($sPNG_File, 16+2)
FileWrite($hFile, '0x89504E470D0A1A0A0000000D494844520000012C000000C8080600000052DFDC55000003EF4944415478DAEDD6A16D16001485513A000BC0001D800118A003E0ABEB6BD1D85A6465655D1DAE0A5583C14082403469424853FAC39B80E76E6E72CE04577DB947877F5E001438122CA0C504EB393D02606382F5273D02606382F5941E01B031C17A4C8F00D89860FD4E8F00D89860FD4A8F00D898603DA447006C4CB0EED323003626583FD323003626583FD22300362658DFD223003626585FD323003626585FD2230036265877E911001B13ACCFE911001B13ACDBF408808D09D6A7F408808D09D64D7A04C0C604EB3A3D0260638275951E01B031C1BA4C8F00D898607D4C8F00D898605DA447006C4CB03EA447006C4CB0DEA747006C4CB0CED3230036265867E911001B13ACD3F408808D09D6BBF408808D09D6497A04C0C604EB6D7A04C0C604EB4D7A04C0C604EB383D02606382F52A3D0260E1FB04EB657A05C0C6517A00C096600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A08165043B0801A8205D4102CA086600135040BA82158400DC1026A1C1D0E87F406809509D6CBF408808D09D65CACD7E92100FF33C13A4E8F00D89860BD498F00D89860BD4D8F00D898609DA447006C4CB0DEA547006C4CB04ED3230036265867E911001B13ACF3F408808D09D6FBF408808D09D687F408808D09D6457A04C0C604EB637A04C0C604EB323D0260638275951E01B031C1BA4E8F00D89860DDA447006C4CB03EA547006C4CB06ED323003626589FD3230036265877E911001B13AC2FE911001B13ACAFE911001B13AC6FE911001B13AC1FE911001B13AC9FE911001B13ACFBF408808D09D6437A04C0C604EB577A04C0C604EB777A04C0C604EB313D02606382F5941E01B031C1FA931E01B031C17A4E8F00D898601DD2230036040BA8F117BB6D14DA7E8BBB9F0000000049454E44AE426082')
FileClose($hFile)
Return $sPNG_File
EndFunc
Func _WinAPI_SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
Local Const $AC_SRC_ALPHA = 1
$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
Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam)
If $hWnd = $hCover_GUI And BitAND($wParam, 0xFFFF) Then
WinActivate($hMain_GUI)
EndIf
EndFunc
Func WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
If $hWnd = $hMain_GUI Then
Local $aPos = WinGetPos($hWnd)
Local $aClientSize = WinGetClientSize($hWnd)
Local $iBorder = ($aPos[2] - $aClientSize[0]) / 2
Local $iCaption = $aPos[3] - $aClientSize[1] - $iBorder
WinMove($hCover_GUI, '', $aPos[0] + 3, $aPos[1] + $iCaption)
EndIf
EndFunc