#Include <GUIConstantsEx.au3>
#Include <GDIPlus.au3>
#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>
_GDIPlus_Startup()
Global $hForm, $hPic, $Msg
$hForm = GUICreate('', 200, 200, -1, -1, BitOR($WS_POPUPWINDOW, $WS_SIZEBOX), $WS_EX_LAYERED)
$hPic = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\red.png')
GUIRegisterMsg($WM_SIZING, 'WM_SIZING')
_SetBitmap($hForm, 200, 200)
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $GUI_EVENT_PRIMARYDOWN
_SendMessage($hForm, $WM_SYSCOMMAND, 0xF012, 0) ; $SC_DRAGMOVE = 0xF012
EndSwitch
WEnd
_GDIPlus_Shutdown()
Func _SetBitmap($hWnd, $iWidth, $iHeight)
Local $hBitmap, $hImage, $hGraphic, $hPen
$hImage = DllCall($ghGDIPDll, 'int', 'GdipGetImageThumbnail', 'ptr', $hPic, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr', 0, 'ptr', 0)
$hImage = $hImage[4]
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
$hPen = _GDIPlus_PenCreate(0xFFFF0000)
_GDIPlus_GraphicsDrawRect($hGraphic, 0, 0, $iWidth - 1, $iHeight - 1, $hPen)
_GDIPlus_PenDispose($hPen)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, 255, 1)
EndFunc ;==>_SetBitmap
Func WM_SIZING($hWnd, $iMsg, $wParam, $lParam)
Local $tRect
Switch $hWnd
Case $hForm
$tRect = DllStructCreate($tagRECT, $lParam)
_SetBitmap($hWnd, DllStructGetData($tRect, 3) - DllStructGetData($tRect, 1), DllStructGetData($tRect, 4) - DllStructGetData($tRect, 2))
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZING