GUI的Input框闪动问题
想实现的功能是当选择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 编辑 ] 既然是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
So easy.
Thank you very much. 循环不停设置启用/禁用控件当然会闪
页:
[1]