找回密码
 加入
搜索
查看: 1195|回复: 3

GUI的Input框闪动问题

[复制链接]
发表于 2009-4-16 20:35:17 | 显示全部楼层 |阅读模式
想实现的功能是当选择test1时,test1的输入框可用,test2的输入框置灰
选择test2时,test2的输入框可用,test1的输入框置灰不可用。
出现的问题是,input框一直在闪动,哪位大虾帮我解决一下这个问题呀?请教各位。
#include <GUIConstants.au3>

Global $Input1
Global $Input2

GUICreate("test", 500, 230)

$Radio1 = GUICtrlCreateRadio("test1", 10, 10, 100, 20)        
$Lable1 = GUICtrlCreateLabel("test1", 40, 40, 130, 20)        
$Input1 = GUICtrlCreateInput("", 130+45, 40-5, 235, 20)

$Radio2 =  GUICtrlCreateRadio("test2", 10, 110, 100+10, 20)        
$Lable2 = GUICtrlCreateLabel("test2", 40, 140, 100, 20)        
$Input2 = GUICtrlCreateInput("", 130, 140-5, 280, 20)

GUICtrlSetState ($Radio1, $GUI_CHECKED)        
GUICtrlSetState($Input2, $GUI_DISABLE)

$Button_Cancel = GUICtrlCreateButton ("Cancel",  300, 350, 70)        

GUISetState (@SW_SHOW)

while(1)
        
        _CheckInput($Radio1, $Radio2)
        
        $msg = GUIGetMsg()        

                Select
                        Case $msg = $Button_Cancel Or $msg = $GUI_EVENT_CLOSE
                                ExitLoop
                EndSelect
WEnd

Func _CheckInput($Radio1, $Radio2)
        
        $Radio1_State = GUICtrlRead($Radio1)
        $Radio2_State = GUICtrlRead($Radio2)
        
        if $Radio1_State = $GUI_CHECKED Then

                GUICtrlSetState($Input2, $GUI_DISABLE)                
                GUICtrlSetState($Input1, $GUI_ENABLE)
                
        ElseIf $Radio2_State = $GUI_CHECKED Then

                GUICtrlSetState($Input1, $GUI_DISABLE)                
                GUICtrlSetState($Input2, $GUI_ENABLE)
                
        EndIf        

EndFunc


[ 本帖最后由 ipgss 于 2009-4-16 22:18 编辑 ]
发表于 2009-4-16 21:49:33 | 显示全部楼层
既然是Radio控件,直接用控件事件不就好了?

#include <GUIConstants.au3>

Global $Input1
Global $Input2

GUICreate("test", 500, 230)

$Radio1 = GUICtrlCreateRadio("test1", 10, 10, 100, 20)
$Lable1 = GUICtrlCreateLabel("test1", 40, 40, 130, 20)
$Input1 = GUICtrlCreateInput("", 130+45, 40-5, 235, 20)

$Radio2 =  GUICtrlCreateRadio("test2", 10, 110, 100+10, 20)
$Lable2 = GUICtrlCreateLabel("test2", 40, 140, 100, 20)
$Input2 = GUICtrlCreateInput("", 130, 140-5, 280, 20)

GUICtrlSetState($Radio1, $GUI_CHECKED)
GUICtrlSetState($Input2, $GUI_DISABLE)

$Button_Cancel = GUICtrlCreateButton ("Cancel",  300, 350, 70)

GUISetState (@SW_SHOW)

While 1
        $msg = GUIGetMsg()

        Switch $msg
                Case $Button_Cancel, $GUI_EVENT_CLOSE
                        ExitLoop
                Case $Radio1
                        GUICtrlSetState($Input2, $GUI_DISABLE)
                        GUICtrlSetState($Input1, $GUI_ENABLE)
                Case $Radio2
                        GUICtrlSetState($Input1, $GUI_DISABLE)
                        GUICtrlSetState($Input2, $GUI_ENABLE)
        EndSwitch
WEnd
 楼主| 发表于 2009-4-16 22:18:04 | 显示全部楼层
So easy.  
Thank you very much.
发表于 2009-4-17 01:58:49 | 显示全部楼层
循环不停设置启用/禁用  控件当然会闪
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-10 05:26 , Processed in 0.073390 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表