► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
$cat = @TempDir & "\cat.jpg"
InetGet("http://affz.free.fr/brol/cat.jpg", $cat)
$gui2 = GUICreate("g1", 288, 216, -1, 50, $WS_POPUP)
$btn = GuiCtrlCreateButton("ici", 250, 180, 30, 20)
GUICtrlSetOnEvent(-1, "_Win")
$pic = GuiCtrlCreatePic("", 0, 0, 288, 216)
GUICtrlSetOnEvent(-1, "_Miaou")
GUICtrlSetImage (-1, $cat)
$pos = WinGetPos($gui2)
$gui = GUICreate("Grat", 284, 216, -1, $pos[1]-30, -1, $WS_EX_LAYERED)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Bye")
$graph = GUICtrlCreateGraphic (0, 0, 284, 216)
GUICtrlSetOnEvent(-1, "_Dro")
GUICtrlSetBkColor($graph, 0x000000)
GUICtrlSetGraphic ($graph, $GUI_GR_PENSIZE, 10)
GUICtrlSetGraphic ($graph, $GUI_GR_COLOR, 0xabcdef)
_WinAPI_SetLayeredWindowAttributes($gui, 0xabcdef)
GUISetState(@SW_SHOWNA, $gui2)
GUISetState(@SW_SHOW, $gui)
WinSetOnTop($gui, "", 1)
_WinAPI_SetWindowPos($gui2, $gui, -1, -1, -1, -1, BitOR(0x0001, 0x0002, 0x0200))
GUIRegisterMsg($WM_MOVE, "WM_MOVE")
GUIRegisterMsg($WM_ACTIVATEAPP, "WM_ACTIVATEAPP")
While 1
Sleep(1)
$a = GUIGetCursorInfo($gui2)
If not WinActive($gui) and $a[4] = $btn Then _
_WinAPI_SetWindowPos($gui2, $gui, -1, -1, -1, -1, BitOR(0x0001, 0x0002, 0x0200))
WEnd
;===============================================
Func _Dro()
If _IsPressed("01") Then
$aSP = MouseGetPos()
GUICtrlSetGraphic ($graph, $GUI_GR_MOVE, $aSP[0], $aSP[1])
$n = 0
Do
$n += 1
$aMP = MouseGetPos()
If $aMP[0] = $aSP[0] And $aMP[1] = $aSP[1] Then ContinueLoop
GUICtrlSetGraphic ($graph, $GUI_GR_LINE, $aMP[0], $aMP[1])
If $n > 10 Then
GUICtrlSetGraphic ($graph,$GUI_GR_REFRESH)
$n = 0
EndIf
$aSP = $aMP
Until Not _IsPressed("01")
EndIf
EndFunc
Func _Miaou()
WinSetOnTop($gui, "", 1)
Msgbox(0,"", " miaou")
EndFunc
Func _Win()
Msgbox(0,"", " gagné !")
_Bye()
EndFunc
Func _Bye()
GuiDelete($gui2)
Exit
EndFunc
Func WM_MOVE($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $wParam, $lParam
Local $aPos = WinGetPos($gui)
WinMove($gui2, "", $aPos[0] , $aPos[1]+30 )
EndFunc
Func WM_ACTIVATEAPP($hWnd, $Msg, $wParam, $lParam)
#forceref $hWnd, $Msg, $wParam, $lParam
WinSetOnTop($gui, "", 1)
_WinAPI_SetWindowPos($gui2, $gui, -1, -1, -1, -1, BitOR(0x0001, 0x0002, 0x0200))
EndFunc
Func _WinAPI_SetLayeredWindowAttributes($hWnd, $i_transcolor, $Transparency = 255, $dwFlags = 0x03, $isColorRef = False)
If $dwFlags = Default Or $dwFlags = "" Or $dwFlags < 0 Then $dwFlags = 0x03
If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $aResult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hWnd, "dword", $i_transcolor, "byte", $Transparency, "dword", $dwFlags)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0]
EndFunc ;==>_WinAPI_SetLayeredWindowAttributes
Func _WinAPI_SetWindowPos($hWnd, $hAfter, $iX, $iY, $iCX, $iCY, $iFlags)
Local $aResult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hWnd, _
"hwnd", $hAfter, "int", $iX, "int", $iY, "int", $iCX, "int", $iCY, "uint", $iFlags)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0]
EndFunc ;==>_WinAPI_SetWindowPos