笨办法!主要还是你的代码逻辑有点乱,同一个数组进行了多次赋值。
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
If FileExists(@ScriptDir & "\Tab.ini") = 0 Then
MsgBox(64 + 0, "错误!", "请将配置文件放置于" & @ScriptDir & "\Tab.ini 再运行!")
Exit
EndIf
Dim $q = 0
Dim $Pic[5]
Dim $with = 60
Dim $x, $y
If $q >= 4 Then
Dim $max = $q
Else
Dim $max = 4
EndIf
Global $Check[$max + 1]
GUICreate('MyGUI', 705, 409)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic('img_bg.bmp', 0, 0, 705, 369)
GUICtrlSetState(-1, $GUI_DISABLE)
For $i = 0 To $max
$Pic[$i] = GUICtrlCreatePic(@ScriptDir & '\img_black.bmp', 10, 24 + 50 * $i, 162, 49)
GUICtrlCreateLabel('Tabsheet' & $i, 21, 40 + 50 * $i, 140, 18, $SS_CENTER)
GUICtrlSetFont(-1, 11, 400, 0, 'Tahoma')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
Next
$Tab = GUICtrlCreateTab(172 + 4, 10 + 4, 523 - 8, 349 - 8)
GUICtrlSetState(-1, $GUI_DISABLE)
For $t = 0 To $max
GUICtrlCreateTabItem('Tabsheet' & $t)
For $i = 1 To $max
$Check[$i] = GUICtrlCreateCheckbox("", 182, 51 + $with * ($i - 1), 13, 13);建立Checkbox
If IniRead(@ScriptDir & "\Tab.ini", "tab" & $t, "Checkbox" & $i, "") = 1 Then
GUICtrlSetState($Check[$i], $GUI_CHECKED)
EndIf
If $x = '' Then $x = $Check[1]
Next
Next
$y = $Check[$max]
GUICtrlCreateTabItem('')
$Label1 = GUICtrlCreateLabel("0", 23, 382, 100, 14)
$Checkbox1 = GUICtrlCreateCheckbox(" 全选/不选", 326, 382, 80, 14)
GUISetState()
$Item = -1
$Over = -1
While 1
$Info = GUIGetCursorInfo()
If @error Then
If $Over <> -1 Then
GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp')
EndIf
$Over = -1
Else
$Index = _Index($Info[4])
If $Index <> $Over Then
If $Over <> -1 Then
GUICtrlSetImage($Pic[$Over], @ScriptDir & '\img_black.bmp')
EndIf
If ($Index <> -1) And ($Index <> $Item) Then
GUICtrlSetImage($Pic[$Index], @ScriptDir & '\img_over.bmp')
$Over = $Index
Else
$Over = -1
EndIf
EndIf
EndIf
$Msg = GUIGetMsg()
If $Item = -1 Then
$Msg = $Pic[0]
$Item = 1
EndIf
Switch $Msg
Case 0
ContinueLoop
Case -3
Exit
Case $Pic[0] To $Pic[UBound($Pic) - 1]
If $Msg <> $Pic[$Item] Then
GUICtrlSetImage($Pic[$Item], @ScriptDir & '\img_black.bmp')
GUICtrlSetColor($Pic[$Item] + 1, 0xFFFFFF)
GUICtrlSetImage($Msg, @ScriptDir & '\img_white.bmp')
GUICtrlSetColor($Msg + 1, 0x313A42)
$Item = _Index($Msg)
GUICtrlSendMsg($Tab, $TCM_SETCURFOCUS, $Item, 0)
$Over = -1
$Label1 = GUICtrlCreateLabel(GUICtrlRead($Tab), 23, 382, 100, 14)
EndIf
Case $Checkbox1
;Beep(1000, 50)
all()
EndSwitch
WEnd
Func _Index($CtrlID)
For $i = 0 To UBound($Pic) - 1
If ($CtrlID = $Pic[$i]) Or ($CtrlID = $Pic[$i] + 1) Then
Return $i
EndIf
Next
Return -1
EndFunc ;==>_Index
Func all()
$B = GUICtrlRead($Label1)
For $i = $x To $y
If GUICtrlRead($Checkbox1) = 1 Then
;IniWrite(@ScriptDir & "\Tab.ini", "tab" & $B, "Checkbox" & $i, "1")
GUICtrlSetState($i, 1)
Else
GUICtrlSetState($i, 4)
;IniWrite(@ScriptDir & "\Tab.ini", "tab" & $B, "Checkbox" & $i, "")
EndIf
Next
EndFunc ;==>all
|