Code : Tout sélectionner
#cs
Réalisation du Nid d'abeille...
#ce
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;#NoTrayIcon
Opt("GUIOnEventMode", 1)
; [x, y, l, h, b] : centre de l'alvéole en [x,y] de taille [l,h] et biseau de b dans les coins
Global $alveoles[14][5] = [ _
[20,40,40,80,20], _
[72,40,40,80,20], _
[124,40,40,80,20], _
[176,40,40,80,20], _
[228,40,40,80,20], _
[46,106,40,80,20], _
[98,106,40,80,20], _
[150,106,40,80,20], _
[201,106,40,80,20], _
[20,172,40,80,20], _
[72,172,40,80,20], _
[124,172,40,80,20], _
[176,172,40,80,20], _
[228,172,40,80,20] _
]
$hMainGUI = GUICreate("Nid d'abeille",750,450)
GUISetOnEvent($GUI_EVENT_CLOSE, "MenuEvents")
$chx1 = GUICtrlCreateGraphic(5,5,228+40/2,172+80/2)
GUICtrlSetBkColor($chx1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($chx1, "MenuEvents")
For $i = 0 To UBound($alveoles)-1
dessinerAlveole($chx1, $alveoles[$i][0],$alveoles[$i][1],$alveoles[$i][2],$alveoles[$i][3],$alveoles[$i][4], 0x55FF00)
Next
GUISetState()
While 1
Sleep(10)
WEnd
Exit
Func dessinerAlveole($graphic, $x,$y, $l,$h, $b, $couleur)
GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, 0x00, $couleur)
GUICtrlSetGraphic($graphic, $GUI_GR_MOVE, $x-$l/2, $y-$h/2+$b)
GUICtrlSetGraphic($graphic, $GUI_GR_LINE, $x-$l/2, $y+$h/2-$b)
GUICtrlSetGraphic($graphic, $GUI_GR_LINE, $x, $y+$h/2)
GUICtrlSetGraphic($graphic, $GUI_GR_LINE, $x+$l/2, $y+$h/2-$b)
GUICtrlSetGraphic($graphic, $GUI_GR_LINE, $x+$l/2, $y-$h/2+$b)
GUICtrlSetGraphic($graphic, $GUI_GR_LINE, $x, $y-$h/2)
GUICtrlSetGraphic($graphic, $GUI_GR_MOVE, $x-$l/2, $y-$h/2+$b)
EndFunc
Func MenuEvents()
Local $Msg = @GUI_CtrlID
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $chx1
Local $opt = Opt("MouseCoordMode")
Opt("MouseCoordMode",2)
Local $mouseCoord = MouseGetPos()
Opt("MouseCoordMode",$opt)
Local $graphicCoord = ControlGetPos($hMainGUI,"",$chx1)
For $i = 0 To UBound($alveoles)-1
If _
Abs($mouseCoord[0]-($alveoles[$i][0]+$graphicCoord[0]))<$alveoles[$i][2]/2 And _
Abs($mouseCoord[1]-($alveoles[$i][1]+$graphicCoord[1]))<$alveoles[$i][3]/2 And _
Abs($mouseCoord[0]-($alveoles[$i][0]+$graphicCoord[0]))+Abs($mouseCoord[1]-($alveoles[$i][1]+$graphicCoord[1]))<$alveoles[$i][2]/2+$alveoles[$i][3]/2-$alveoles[$i][4] Then
MsgBox(0,"Click, Click", "Le graphique est cliqué, alvéole n°"&$i)
EndIf
Next
EndSwitch
EndFunc