Code : Tout sélectionner
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
Global $hGUI2, $hImage
; gui principale
$hGUI2 = GUICreate("Test", 400, 400, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
$exit = GuiCtrlCreateLabel("", 290, 80, 30, 30)
GUICtrlSetState(-1, $GUI_ONTOP)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\GUI.png")
SetBitMap($hGUI2, $hImage, 255)
; gui pour placer des controles
$gui_bis = GUICreate("", 400, 400, 0, 0, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_COMPOSITED + $WS_EX_MDICHILD, $hGUI2)
$btn = GuiCtrlCreateButton("bouton", 200, 200, 60, 30) ; exemple ^^
GUICtrlSetBkColor(-1, 0xf0f0ff)
GUISetBkColor(0x00FF00)
_WinAPI_SetLayeredWindowAttributes($gui_bis, 0x00FF00)
GUISetState(@SW_SHOWNOACTIVATE) ; pour éviter le focus moche sur le controle
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
While 1
$msg = GuiGetMsg()
If $msg = $exit Then ExitLoop
If $msg = $btn Then Msgbox(0,"", "bouton pressé")
Wend
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
;=====================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
if ($hWnd = $hGUI2) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION
EndFunc
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