[已解决]8个复选框如何全选和反选
本帖最后由 dnvplj 于 2014-10-7 21:04 编辑请问各位朋友:如何点“全选”8个复选框全部选中,并按“安装”后按1-8的顺序或按所选进行软件安装,按"全不选"取消全部。#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
EndSwitch
WEnd
用 _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
If $childWndArray[$i] = "Button" Then
$btnStyle = _WinAPI_GetWindowLong($childWndArray[$i], $GWL_STYLE)
If BitAND($btnStyle, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX Then
_SendMessage($childWndArray[$i], $BM_SETCHECK, $BST_CHECKED)
EndIf
EndIf
Next
Else
For $i=1 To $childWndArray
If $childWndArray[$i] = "Button" Then
$btnStyle = _WinAPI_GetWindowLong($childWndArray[$i], $GWL_STYLE)
If BitAND($btnStyle, $BS_AUTOCHECKBOX) = $BS_AUTOCHECKBOX Then
_SendMessage($childWndArray[$i], $BM_SETCHECK, $BST_UNCHECKED)
EndIf
EndIf
Next
EndIf
EndIf
EndFunc
剩下点活你自己搞定吧 回复 3# veket_linux
感谢veket_linux朋友的指教,大问题解决了,小问题我在研究。 按“安装”后按1-8的顺序或按所选进行软件安装,不会了,那个朋友在帮下,多谢了。 学习了,谢谢。 回复 5# dnvplj
读取控件名称,建一个数组 for $i= 0 to 7一个一个运行就行了 回复 7# netegg
感谢元老的回复,看了一下午的帮助了,还是看不懂,还请元老帮助解决为盼,多谢了。 本帖最后由 netegg 于 2014-9-27 18:52 编辑
case button1
if bitand(guictrlread($chcckbox1),$gui_checked) then do1
ifbitand(guictrlread($chcckbox2),$gui_checked) then do2
..... 本帖最后由 dunphy 于 2014-9-27 19:21 编辑
回复 2# veket_linux
亲,善用搜索。来就提示你...
你们A版早就整出来了。看这贴
http://www.autoitx.com/attachment.php?aid=NDc5MHw4M2QxNzgzZXwxNDExODE2NTQxfDc2MmJHRllaZWpYMHhBK0NrVUhLSVlUVXFrL3dsOUthdnZyaEU3d05FdUpzVllB&noupdate=yes
http://www.autoitx.com/forum.php?mod=viewthread&tid=9252&highlight=%B8%B4%D1%A1%BF%F2Checkbox%B2%D9%D7%F7
而且我还在自定义函数区故意把这贴特拿出来举例‘’
http://www.autoitx.com/forum.php?mod=viewthread&tid=45048 回复 2# veket_linux
亲,你的代码中和色彩是咱格弄出来的呢??? 回复 11# dunphy
亲 代码用 your code 括起来 a大的帖子自然是拜读过滴,
只不过很久了........ 干脆自己也写个 前方括号 au后放括号
代码
前方括号 /au后放括号 本帖最后由 dunphy 于 2014-9-28 12:23 编辑
已经搞明白了。在高级编辑贴子的地方,有个A2的图标,点一下,把代码弄在里面就行了。 本帖最后由 dnvplj 于 2014-9-29 08:12 编辑
回复 2# veket_linux
朋友您好:请问,窗体上的“软件1至软件8”和“IOC图标”如何从配置文件中读取,位置不变,多谢了。
页:
[1]
2