Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)
Global Const $AC_SRC_ALPHA = 1
Global $aSP, $gui[3][2]
_GDIPlus_Startup()
$logo = @ScriptDir & "\logo.png"
For $i = 0 to 2
$gui[$i][0] = _CreateGui($i, $logo)
Next
_GDIPlus_Shutdown()
While 1
Sleep(10)
Wend
;==========================================
Func _CreateGui($n, $img)
Local $hImage = _GDIPlus_ImageLoadFromFile($img)
$iX = _GDIPlus_ImageGetWidth ($hImage)
$iY = _GDIPlus_ImageGetHeight ($hImage)
Local $gui0 =GuiCreate("", $iX, $iY, @desktopwidth/2+($iX+10)*$n, 110, $WS_POPUP, $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_GereMoiCeTruc")
GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_Exit")
SetBitMap($gui0, $hImage, 200)
GuiSetState()
_GDIPlus_ImageDispose($hImage)
Return $gui0
EndFunc
Func _GereMoiCeTruc()
$aSP = MouseGetPos()
For $i = 0 to 2
$posall = WinGetPos($gui[$i][0])
$gui[$i][1] = $posall[0]
Next
Do
$aMP = MouseGetPos()
$dif = $aMP[0] - $aSP[0]
For $i = 0 to 2
If $gui[$i][1]+$dif > @desktopwidth-$posall[2] Then $gui[$i][1] -= @desktopwidth-$posall[2]
If $gui[$i][1]+$dif < 0 Then $gui[$i][1] += @desktopwidth-$posall[2]
WinMove($gui[$i][0], "", $gui[$i][1]+$dif, 110)
Next
Until Not _IsPressed("01")
$aNP = MouseGetPos()
If $aNP[0] = $aSP[0] Then _Events()
EndFunc
Func _Events()
Switch @GUI_WinHandle
Case $gui[0][0]
Msgbox(0,"", "cliqué 1")
Case $gui[1][0]
Msgbox(0,"", "cliqué 2")
Case $gui[2][0]
Msgbox(0,"", "cliqué 3")
EndSwitch
EndFunc
Func _Exit()
Exit
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", $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