Opt("GUIOnEventMode", 1)
Local $Checkbox[9], $s = 0
$Form1 = GUICreate("Test", 300, 300)
GUISetOnEvent(-3, "guiclick")
For $i = 0 To 8
$Checkbox[$i] = GUICtrlCreateCheckbox("待定", 30 + Floor($i / 3) * 70, 30 + Mod($i, 3) * 70, 50, 25)
GUICtrlSetOnEvent(-1, "guiclick")
Next
$button = GUICtrlCreateButton("统计", 125, 260, 50, 25)
GUICtrlSetOnEvent(-1, "guiclick")
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func guiclick()
Switch @GUI_CtrlId
Case -3
Exit
Case $button
MsgBox(0, 0, "一共选择了" & $s & "个")
Case $Checkbox[@GUI_CtrlId - 3]
If GUICtrlRead($Checkbox[@GUI_CtrlId - 3]) = 1 Then $s += 1
If GUICtrlRead($Checkbox[@GUI_CtrlId - 3]) = 4 Then $s -= 1
EndSwitch
EndFunc
|