用 _WinAPI_EnumChildWindows得到子窗口句柄和类名
把类名为button的过滤出来
把button的风格为checkbox($BS_AUTOCHECKBOX)的过滤出来
发消息改变其状态
#Include <Constants.au3 >
#Include <WinAPI.au3>
#Include <WinAPIEx.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\form_softinstall.kxf
$Form_SoftInstall = GUICreate("Soft_Name", 552, 393, 193, 131)
GUISetBkColor(0xC0C0C0)
$Pic1 = GUICtrlCreatePic("C:\WINDOWS\Web\Wallpaper\bliss.jpg", 0, 0, 551, 92)
$Group_ChooseSoft = GUICtrlCreateGroup(" 选择软件: ", 8, 96, 537, 245, -1, $WS_EX_TRANSPARENT)
$Checkbox1 = GUICtrlCreateCheckbox("软件1", 64, 136, 193, 33)
$Checkbox2 = GUICtrlCreateCheckbox("软件2", 64, 193, 193, 33)
$Checkbox3 = GUICtrlCreateCheckbox("软件3", 64, 243, 193, 33)
$Checkbox4 = GUICtrlCreateCheckbox("软件4", 64, 308, 193, 17)
$Checkbox5 = GUICtrlCreateCheckbox("软件5", 336, 144, 193, 17)
$Checkbox6 = GUICtrlCreateCheckbox("软件6", 336, 199, 193, 17)
$Checkbox7 = GUICtrlCreateCheckbox("软件7", 336, 253, 193, 17)
$Checkbox8 = GUICtrlCreateCheckbox("软件8", 336, 308, 193, 17)
$Icon2 = GUICtrlCreateIcon("", -1, 24, 195, 25, 25)
$Icon1 = GUICtrlCreateIcon("", -1, 24, 140, 25, 25)
$Icon3 = GUICtrlCreateIcon("", -1, 24, 249, 25, 25)
$Icon4 = GUICtrlCreateIcon("", -1, 24, 304, 25, 25)
$Icon5 = GUICtrlCreateIcon("", -1, 296, 140, 25, 25)
$Icon6 = GUICtrlCreateIcon("", -1, 296, 195, 25, 25)
$Icon7 = GUICtrlCreateIcon("", -1, 296, 249, 25, 25)
$Icon8 = GUICtrlCreateIcon("", -1, 296, 304, 25, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("安装", 352, 360, 75, 25)
$Button2 = GUICtrlCreateButton("退 出", 440, 360, 75, 25)
$Radio1 = GUICtrlCreateRadio("全选", 216, 364, 57, 17)
$Radio2 = GUICtrlCreateRadio("全不选", 280, 364, 65, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Radio1
SetAllCheckBox(True)
Case $Radio2
SetAllCheckBox(False)
EndSwitch
WEnd
Func SetAllCheckBox($status)
$childWndArray = _WinAPI_EnumChildWindows($Form_SoftInstall)
If IsArray($childWndArray) Then
If $status Then
For $i=1 To $childWndArray[0][0]
If $childWndArray[$i][1] = "Button" Then
$btnStyle = _WinAPI_GetWindowLong($childWndArray[$i][0], $GWL_STYLE)
If BitAND($btnStyle, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX Then
_SendMessage($childWndArray[$i][0], $BM_SETCHECK, $BST_CHECKED)
EndIf
EndIf
Next
Else
For $i=1 To $childWndArray[0][0]
If $childWndArray[$i][1] = "Button" Then
$btnStyle = _WinAPI_GetWindowLong($childWndArray[$i][0], $GWL_STYLE)
If BitAND($btnStyle, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX Then
_SendMessage($childWndArray[$i][0], $BM_SETCHECK, $BST_UNCHECKED)
EndIf
EndIf
Next
EndIf
EndIf
EndFunc
|