#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GdiPlus.au3>
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUIRegisterMsg($WM_NCLBUTTONDOWN, 'WM_NCLBUTTONDOWN')
$gui = GUICreate("1234", 305, 175, -1, @DesktopHeight - 250, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$kzgui = GUICreate("123", 20, 20, -1, @DesktopHeight - 198, $WS_POPUP, BitOR($WS_EX_MDICHILD, $WS_EX_LAYERED, $WS_EX_TOPMOST), $gui)
Global $g_Dw_UI_Close_LeftMouseDown = False
_GDIPlus_Startup()
Global $hBitmap = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\back.png")
SetBitmap($gui, $hBitmap, 255)
Global $hImage1 = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\DeskLyricPng\Lock.png")
SetBitmap($kzgui, $hImage1, 127)
GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_SHOW, $kzgui)
While 1
$gMsg = GUIGetMsg()
Switch $gMsg
Case $GUI_EVENT_CLOSE
If $g_Dw_UI_Close_LeftMouseDown Then exitfunc()
EndSwitch
WEnd
Func exitfunc()
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hBitmap)
_GDIPlus_Shutdown()
GUIDelete($gui)
GUIDelete($kzgui)
Exit
EndFunc ;==>exitfunc
Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam)
Switch $hWnd
Case $gui
If $g_Dw_UI_Close_LeftMouseDown Then $g_Dw_UI_Close_LeftMouseDown = False
SetBitmap($kzgui, $hImage1, 127)
Return $HTCAPTION
Case $kzgui
If $g_Dw_UI_Close_LeftMouseDown Then
_SendMessage($gui, $WM_SYSCOMMAND, 0xF060, 0)
EndIf
SetBitmap($kzgui, $hImage1, 255)
Return $HTCLOSE
EndSwitch
EndFunc ;==>WM_NCHITTEST
Func WM_NCLBUTTONDOWN($hWnd, $Msg, $wParam, $lParam)
Switch $hWnd
Case $kzgui
If $wParam = $HTCLOSE Then
$g_Dw_UI_Close_LeftMouseDown = True
EndIf
EndSwitch
EndFunc ;==>WM_NCLBUTTONDOWN
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", 1)
_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 ;==>SetBitmap