本帖最后由 netegg 于 2011-4-27 22:05 编辑
忽然想到一个问题,楼主的全选和推荐操作是单向的,只管选不管读吧,具体的操作应该是其它复选的事情
虽说有点绕,楼主看看这段代码,肯定是没写对,不过可能可以参考一下#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>
;Global Const $GUI_CHECKED = 1
;Global Const $GUI_INDETERMINATE = 2
;Global Const $GUI_UNCHECKED = 4
Dim $Checkbox[21]
Dim $choose = _arraycreate(2, 5, 6, 7)
Dim $sChoose = '2,5,6,7'
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
For $i = 1 To 18
$Checkbox[$i] = GUICtrlCreateCheckbox("Checkbox" & $i, 48, 32 + 16 * ($i - 1), 97, 17)
Next
$Checkbox[19] = GUICtrlCreateCheckbox("推荐", 392, 312, 97, 17)
$Checkbox[20] = GUICtrlCreateCheckbox("全选", 392, 352, 97, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
If $nMsg = $GUI_EVENT_CLOSE Then Exit
For $i = 1 To 20
If $nMsg = $Checkbox[$i] Then
;判断推荐复选
If $i = 19 Then
For $j In $choose
GUICtrlSetState($Checkbox[$j], GUICtrlRead($Checkbox[19]))
Next
For $j = 1 To 18
If GUICtrlRead($Checkbox[$j]) = 4 Then
GUICtrlSetState($Checkbox[20], 4)
EndIf
Next
ElseIf $i = 20 Then ;判断全选复选
For $j = 1 To 19
GUICtrlSetState($Checkbox[$j], GUICtrlRead($Checkbox[20]))
Next
ElseIf Not ($i = 19 Or $i = 20) Then ;判断一般复选
GUICtrlSetState($Checkbox[20], GUICtrlRead($Checkbox[$i]))
If StringInStr($sChoose, $i) Then GUICtrlSetState($Checkbox[19], GUICtrlRead($Checkbox[$i]))
For $j = 1 To 18
;检查所有一般复选
If GUICtrlRead($Checkbox[$j]) = 4 Then
GUICtrlSetState($Checkbox[20], 4) ; 取消全选复选
If StringInStr($sChoose, $j) Then GUICtrlSetState($Checkbox[19], 4)
EndIf
Next
EndIf
EndIf
Next
WEnd
补齐了,试试看对不对 |