一个例子
#include <GUIConstantsEx.au3>
GUICreate(" GUI 复选框") ; 创建居中显示的对话框窗口
$checkCN1 = GUICtrlCreateCheckbox("复选框 1", 10, 10)
$checkCN2 = GUICtrlCreateCheckbox("复选框 2", 10, 30)
$checkCN3 = GUICtrlCreateCheckbox("复选框 3", 10, 50)
$checkCN4 = GUICtrlCreateCheckbox("复选框 4", 10, 70)
$checkCN5 = GUICtrlCreateCheckbox("复选框 5", 10, 90)
$checkCN6 = GUICtrlCreateCheckbox("复选框 6", 10, 110)
$checkCN7 = GUICtrlCreateCheckbox("复选框 7", 10, 130)
$checkCN8 = GUICtrlCreateCheckbox("复选框 8", 10, 150)
$checkCN9 = GUICtrlCreateCheckbox("复选框 9", 10, 170)
$checkCN10 = GUICtrlCreateCheckbox("复选框 10", 10, 190)
$btn = GUICtrlCreateButton("全选", 10, 220)
$btn2 = GUICtrlCreateButton("全不选", 10, 250)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $checkCN1
Check($checkCN1)
Case $msg = $checkCN2
Check($checkCN2)
Case $msg = $checkCN3
Check($checkCN3)
Case $msg = $btn
Checkbox()
Case $msg = $btn2
UnCheckbox()
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
Func Check($check)
If GUICtrlRead($check) = $GUI_CHECKED Then _
MsgBox(0, "", "您选择了" & GUICtrlRead($check, 1))
EndFunc ;==>Check
Func Checkbox()
For $i = 1 + 2 To 10 + 2
$s = Eval("checkCN") & Eval("i")
GUICtrlSetState($s, $GUI_CHECKED)
Next
EndFunc ;==>Checkbox
Func UnCheckbox()
For $i = 1 + 2 To 10 + 2
$s = Eval("checkCN") & Eval("i")
GUICtrlSetState($s, $GUI_UNCHECKED)
Next
EndFunc ;==>UnCheckbox
|