Code : Tout sélectionner
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $checkCN,$checkCN1,$checkCN2,$checkCN3, $msg
Local $Boutton_ToutSelectionner,$Boutton_ToutDeSelectionner
GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered
Local $arrayCheckBox[4]=[GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20),GUICtrlCreateCheckbox("CHECKBOX 2", 10, 40, 120, 20), _
GUICtrlCreateCheckbox("CHECKBOX 3", 10, 70, 120, 20),GUICtrlCreateCheckbox("CHECKBOX 4", 10, 100, 120, 20)] ; array contenant les ctrlID des checkBox
$Boutton_ToutSelectionner = GUICtrlCreateButton("Tout Selectionner",150,20,175,50,0)
$Boutton_ToutDeSelectionner = GUICtrlCreateButton("Tout DeSelectionner",150,80,175,50,0)
GUISetState() ; will display an dialog box with 1 checkbox
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $Boutton_ToutSelectionner Then _CheckAll($arrayCheckBox,True)
If $msg = $Boutton_ToutDeSelectionner Then _CheckAll($arrayCheckBox,False)
WEnd
EndFunc ;==>Example
Func _CheckAll($array,$checkOn=True) ; true pour tout cocher; false pour tout décocher
If $checkOn Then
For $i=0 To UBound($array)-1
GUICtrlSetState($array[$i],$GUI_CHECKED)
Next
Else
For $i=0 To UBound($array)-1
GUICtrlSetState($array[$i],$GUI_UNCHECKED)
Next
EndIf
EndFunc