回复 7# akmm88 #include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)
Global $box1, $msg ,$ok,$button1,$box2,$checked,$i,$box3,$ch,$chked
$ch= 0
GUICreate("My GUI Checkbox")
$box1 = GUICtrlCreateCheckbox("box1", 10, 10, 120, 20)
$box2 = GUICtrlCreateCheckbox("box2",10,30,120,20)
$box3 = GUICtrlCreateCheckbox("box3", 10, 50, 120 ,20)
$button1=GUICtrlCreateButton("button1",120,120,120,20)
GUISetState()
GUICtrlSetOnEvent($button1,"ok")
;GUICtrlSetOnEvent($box1,"func1")
For $i = 1 To 2
If GUICtrlRead (Eval("$chkbox"&$i)) = $GUI_CHECKED Then
$ch = $ch + BitShift (1,1-$i )
EndIf
Next
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Func ok()
For $i = 1 To 2
Execute ("func"&$i&"("&$ch&")")
Next
EndFunc
Func func1($ch)
If BitAND($ch,1) = 0 Then
MsgBox(0,$ch,"2")
Return
EndIf
EndFunc
Func func2($ch)
If BitAND($ch,2) = 0 Then
MsgBox(0,$ch,"3")
Return
EndIf
EndFunc
Func func3($ch)
If BitAND($ch,5) = 0 Then
MsgBox(0,$ch,"4")
Return
EndIf
EndFunc
大侠 你觉得 我的代码哪出了问题? |