|
发表于 2010-6-5 13:25:33
|
显示全部楼层
关键思路:AdlibRegister注册一个Adlib 函数监控Radio,根据情况修改Combo和Button的控件状态
#include <GUIConstantsEx.au3>
GUICreate("与radio相关的$GUI_DISABLE问题",600, 300)
$Group1 = GUICtrlCreateGroup("", 200, 56, 385, 41)
$Radio1 = GUICtrlCreateRadio("隐藏", 224, 72, 97, 17)
$Radio2 = GUICtrlCreateRadio("显示", 384, 72, 113, 17)
$Combo1 = GUICtrlCreateCombo("1", 208, 160, 281, 25)
$Button1 = GUICtrlCreateButton("Button1", 504, 160, 81, 25)
$Combo3 = GUICtrlCreateCombo("2", 208, 216, 281, 25)
$Button2 = GUICtrlCreateButton("Button2 ", 504, 216, 81, 25)
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetState($Button1,$GUI_DISABLE)
GUISetState()
AdlibRegister("MyAdlib")
While 1
$nMsg = GUIGetMsg()
select
Case $nmsg = $GUI_EVENT_CLOSE
ExitLoop
Case $nMsg=$Button1
msgbox(1,"","button1")
Case $nMsg=$Button2
msgbox(1,"","button2")
EndSelect
WEnd
Func MyAdlib()
If GUICtrlRead($Radio2) = $GUI_UNCHECKED Then
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetState($Button1,$GUI_DISABLE)
ElseIf GUICtrlRead($Radio2)= $GUI_CHECKED Then
GUICtrlSetState($Combo1,$GUI_ENABLE)
GUICtrlSetState($Button1,$GUI_ENABLE)
EndIf
EndFunc
将判断语句放在while循环也可以达到监控Radio和修改Combo和Button控件状态的目的
不过
自己测试下这种思路与AdlibRegister相比有何缺点?#include <GUIConstantsEx.au3>
GUICreate("My GUI combo",600, 300)
$Group1 = GUICtrlCreateGroup("", 200, 56, 385, 41)
$Radio1 = GUICtrlCreateRadio("1111", 224, 72, 97, 17)
$Radio2 = GUICtrlCreateRadio("2222", 384, 72, 113, 17)
$Combo1 = GUICtrlCreateCombo("1", 208, 160, 281, 25)
$Button1 = GUICtrlCreateButton("Button1", 512, 160, 57, 25)
$Combo3 = GUICtrlCreateCombo("2", 208, 216, 281, 25)
$Button2 = GUICtrlCreateButton("Button2 ", 504, 216, 81, 25)
GUISetState()
While 1
If GUICtrlRead($Radio2) = $GUI_UNCHECKED Then
GUICtrlSetState($Combo1,$GUI_DISABLE)
GUICtrlSetState($Button1,$GUI_DISABLE)
ElseIf GUICtrlRead($Radio2)= $GUI_CHECKED Then
GUICtrlSetState($Combo1,$GUI_ENABLE)
GUICtrlSetState($Button1,$GUI_ENABLE)
EndIf
$nMsg = GUIGetMsg()
select
Case $nmsg = $GUI_EVENT_CLOSE
ExitLoop
Case $nMsg=$Button1
msgbox(1,"","button1")
Case $nMsg=$Button2
msgbox(1,"","button2")
EndSelect
WEnd
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
评分
-
查看全部评分
|