(已解决)GUICtrlCreateCheckbox判断勾选的问题
本帖最后由 xargw 于 2010-8-10 10:36 编辑#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 104, 48, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 112, 104, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
我想让程序实现,如果GUICtrlCreateCheckbox选中,点按钮提示,已选中,否则提示未选中,这个要怎么判断
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 104, 48, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 112, 104, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Checkbox1
GUICtrlSetState(-1, $GUI_CHECKED)
If GUICtrlRead($Checkbox1)=$$GUI_CHECKED Then
Case $Form1
Case $Button1
msgbox((,0),"提示","已选中")
Else
MsgBox(",0","提示","未选中")
endif
EndSwitch
WEnd #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 104, 48, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 112, 104, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
MsgBox(4096, "提示", "已选中")
Else
MsgBox(4096, "提示", "未选中")
EndIf
EndSwitch
WEnd 本帖最后由 水木子 于 2010-8-9 10:22 编辑
回复 2# 破帽遮颜
呵呵!撞车啦!#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("Form1", 600, 450)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 100, 50, 100, 17)
$Button1 = GUICtrlCreateButton("Button1", 100, 100, 75, 25)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
Case $Checkbox1
Case $Button1
If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then
MsgBox(0, '', '已勾选')
Else
MsgBox(0, '', '未勾选')
EndIf
EndSwitch
WEnd 谢谢,可以用 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then
各位能解释一下么? If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
guictrlread读取$gui_checked有值表示选中,没值表示没选中,是这个意思么? 都有值,=1为选中;=4为未选中 If GUICtrlRead($Checkbox1) = $GUI_CHECKED then
这句怎么理解是=1呢 你可以去看看 GUICtrlSetState 这个函数,下面有控件状态表!
看完你就知道是怎么回事了。 $GUI_CHECKED 是个常量,值为1 回复 2# 破帽遮颜
朋友您好,如果是12个复选框,如何判断:选中还是没有选中? 回复 11# dnvplj
每个控件分配一个变量,通过查询GUICtrlRead(变量)是否等于1判断选中否。 回复 12# 破帽遮颜
能否结合2楼的代码,给个范例,小弟对此还不是很熟悉,谢谢指教。 我有个类似的问题,在这里,帮忙看一下
http://www.autoitx.com/forum.php?mod=viewthread&tid=51448&extra=
页:
[1]