如何用一个统一的办法代替这不确定数量的控件点击事件
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $IconIf BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
Case $nMsg = $LabelA Or $nMsg = $LabelB Or $nMsg = $Icon
If BitAND(GUICtrlRead($Checkbox),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox,$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox,$GUI_CHECKED)
EndIf
上面代码倒是可行,但是如果控件数量继续增多的话,岂不是代码无限循环了,有精简的办法吗 本帖最后由 q410225 于 2016-12-10 16:31 编辑
如果这个格式没问题的话
可以定义一个变量
local $i=1
while $i<111111111
Case $nMsg = $LabelA[$i] Or $nMsg = $LabelB[$i] Or $nMsg = $Icon[$i]
If BitAND(GUICtrlRead($Checkbox[$i]),$GUI_CHECKED) Then
GUIctrlSetState($Checkbox[$i],$GUI_UNCHECKED)
Else
GUIctrlSetState($Checkbox[$i],$GUI_CHECKED)
EndIf
$i+=1
wend
这样就没问题了 试一下,我也遇到这个问题
页:
[1]