忘记问的问题。
#include <ButtonConstants.au3>#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 139, 284, 193, 125)
$Checkbox1 = GUICtrlCreateCheckbox("注册1", 32, 24, 105, 33)
$Checkbox2 = GUICtrlCreateCheckbox("注册2", 32, 64, 105, 25)
$Checkbox3 = GUICtrlCreateCheckbox("注册3", 32, 104, 73, 17)
$Checkbox4 = GUICtrlCreateCheckbox("注册4", 32, 144, 89, 17)
$Button1 = GUICtrlCreateButton("全选", 16, 192, 97, 25, 0)
$Button2 = GUICtrlCreateButton("全不选", 16, 220, 97, 25, 0)
$Button3 = GUICtrlCreateButton("确定", 16, 249, 97, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
For $i=1 to 4
$T="Checkbox"&$i
GUICtrlSetState(Eval($T),$GUI_CHECKED)
Next
Case $Button2
For $i=1 to 4
$T="Checkbox"&$i
GUICtrlSetState(Eval($T),$GUI_UNCHECKED)
Next
Case $Button3
If $nMsg = $Button3 Then
GUISetState (@SW_HIDE )
If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then MsgBox(64,"","你按下了CHECKBOX1")
If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then MsgBox(64,"","你按下了CHECKBOX2")
If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then MsgBox(0,"","你按下了CHKCKBOX3")
If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then MsgBox(0,"","你按下了CHKCKBOX4")
ExitLoop
EndIf
EndSwitch
WEnd
有没有更简单的方法写$Button3后的代码?
[ 本帖最后由 xg911335 于 2008-10-8 20:52 编辑 ] Case $Button3
If $nMsg = $Button3 Then
GUISetState (@SW_HIDE )
For $i = $Checkbox1 to $Checkbox4
If GUICtrlRead($i) = $GUI_CHECKED Then MsgBox(64,"","你按下了[" & GUICtrlRead($i,1) & "]")
Next
ExitLoop
EndIf 原帖由 aa147147 于 2008-10-6 00:32 发表 http://www.autoitx.com/images/common/back.gif
Case $Button3
If $nMsg = $Button3 Then
GUISetState (@SW_HIDE )
For $i = $Checkbox1 to $Checkbox4
...
$checkbox1到$checkbox4,这样行吗?这两个谁大谁小姑且不论,步长是多少?建个数组倒是可以,四个复选框不算多,多了就没法用了
[ 本帖最后由 netegg 于 2008-10-6 00:39 编辑 ] 就算是多了,如果,他们是在一起下去的,1-100,都可以这样子来写 使用事件模式,注册checkbox1-4至同一事件 经思考得:(些办法同于全选和全否!此例仅为参考显示,如果要用于不同事件,还是用看起来麻烦的句式!)
Case $Button3
If $nMsg = $Button3 Then
GUISetState(@SW_HIDE)
For $i = 1 To 4
If GUICtrlRead(Eval("Checkbox" & $i)) = $GUI_CHECKED Then MsgBox(64, "", "你按下了")
Next
ExitLoop
EndIf
[ 本帖最后由 liongodmien 于 2008-10-6 11:37 编辑 ] 如果事件不同了?或者复选框有10多个有怎么办? 还差多后一点就完了。顶上去。
[ 本帖最后由 xg911335 于 2008-10-7 17:36 编辑 ]
页:
[1]