【已解决】 请教高手GUICtrlCreateInput提示问题
本帖最后由 ssjoe 于 2010-11-5 00:20 编辑请教高人帮忙解决输入框输入后为何会闪过不停,同时清除第一框的时候按钮灰色,为何清除第二框的时候按钮不变灰色,希望高人帮忙解决一下!
还有可否限制第一框只可以输入数字!#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)
Global Const $WM_NOTIFY = 0x004E
Global Const $WM_CTLCOLOREDIT = 0x0133
$Form1 = GUICreate("Form1", 494, 345, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")
$Button1 = GUICtrlCreateButton("Button1", 320, 64, 121, 25, 0)
$Label1 = GUICtrlCreateLabel("第一框:", 48, 64, 60, 28)
$Label2 = GUICtrlCreateLabel("第二框:", 48, 94, 60, 28)
$Label3 = GUICtrlCreateLabel("", 158, 34, 60, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 128, 64, 169, 25)
$Input2 = GUICtrlCreateInput("", 128, 94, 169, 25)
GUISetState()
GUICtrlSetOnEvent($Button1, "main")
GUIRegisterMsg($WM_NOTIFY, "test")
GUIRegisterMsg($WM_CTLCOLOREDIT, "test")
$getfocus=ControlFocus ( "Form1", "", $Input1)
While 1
Sleep(1000)
WEnd
Func main()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0,"",GUICtrlRead($Input1))
EndSwitch
EndFunc
Func test()
$Select1 = GUICtrlRead($Input1)
If$Select1= "" Then
If BitAND(GUICtrlGetState($Button1), $GUI_ENABLE) Then
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetData($Label3,"")
GUICtrlSetData($Input2,"")
Endif
Else
If BitAND(GUICtrlGetState($Button1), $GUI_DISABLE) Then GUICtrlSetState($Button1, $GUI_ENABLE)
If BitAND(GUICtrlGetState($Select1),$GUI_FOCUS) then
GUICtrlSetData($Label3,GUICtrlRead($Input1))
GUICtrlSetData($Input2,GUICtrlRead($Input1))
Endif
EndIf
EndFunc #include <GuiConstants.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 1)
Global Const $WM_NOTIFY = 0x004E
Global Const $WM_CTLCOLOREDIT = 0x0133
$Form1 = GUICreate("Form1", 494, 345, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")
$Button1 = GUICtrlCreateButton("Button1", 320, 64, 121, 25, 0)
$Label1 = GUICtrlCreateLabel("第一框:", 48, 64, -1, 28)
$Label2 = GUICtrlCreateLabel("第二框:", 48, 94, -1, 28)
$Label3 = GUICtrlCreateLabel("", 158, 34, 400, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 128, 64, 169, 25, $ES_NUMBER)
$Input2 = GUICtrlCreateInput("", 128, 94, 169, 25)
GUISetState()
GUICtrlSetOnEvent($Button1, "main")
GUIRegisterMsg($WM_NOTIFY, "test")
GUIRegisterMsg($WM_CTLCOLOREDIT, "test")
$getfocus = ControlFocus("Form1", "", $Input1)
While 1
Sleep(1000)
WEnd
Func main()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, "", GUICtrlRead($Input1))
EndSwitch
EndFunc ;==>main
Func test($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Switch $lParam
Case GUICtrlGetHandle($Input1)
$Select1 = GUICtrlRead($Input1)
If $Select1 = "" Then
If BitAND(GUICtrlGetState($Button1), $GUI_ENABLE) Then
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetData($Label3, "")
GUICtrlSetData($Input2, "")
EndIf
Else
If BitAND(GUICtrlGetState($Button1), $GUI_DISABLE) Then GUICtrlSetState($Button1, $GUI_ENABLE)
If BitAND(GUICtrlGetState($Select1), $GUI_FOCUS) Then
GUICtrlSetData($Label3, GUICtrlRead($Input1))
GUICtrlSetData($Input2, GUICtrlRead($Input1))
EndIf
EndIf
EndSwitch
EndFunc ;==>test 谢谢您。。。但是问题还没有得到解决。第一个框现在只可以输入数字了,但能否不要提示呢?
还有能否帮忙解决第二个框为空时不要自动恢复第一个框的值,还有第二个框为空时按钮变灰色! 怎么没有热心人回复我一下啊?是否我表达不够清楚呢? 这需要钩子在修改数据前拦截(过滤),论坛有相关帖子,参考P版的经典代码
http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&ptid=9622&pid=87360&fromuid=7644923 能否用别的方法来处理这个问题呢?我的目的就是想第一个$Input1输入的值传到$Input2和$Label3,同时按钮可以启用,当清除$Input2值改变后$Input1、$Label3、按钮都不变,但$Input1值改变,其它都同时变,但当清除$Input2值后按钮同是变灰色,大虾们能否帮我实现这个功能呢? 怎么还没有人能帮上我这个忙啊?痛苦啊。。。 奇怪的设计需求。 #include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
Opt("GUIOnEventMode", 0)
$flag = ""
$Form1 = GUICreate("Form1", 494, 345, 192, 114)
$Button1 = GUICtrlCreateButton("Button1", 320, 64, 121, 25, 0)
$Label1 = GUICtrlCreateLabel("第一框:", 48, 64, 60, 28)
$Label2 = GUICtrlCreateLabel("第二框:", 48, 94, 60, 28)
$Label3 = GUICtrlCreateLabel("", 158, 34, 60, 28)
$Input1 = GUICtrlCreateInput("", 128, 64, 169, 25)
$Input2 = GUICtrlCreateInput("", 128, 94, 169, 25)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, "", GUICtrlRead($Input1))
EndSwitch
$Select1 = GUICtrlRead($Input1)
If $Select1 = "" Then
If BitAND(GUICtrlGetState($Button1), $GUI_ENABLE) = $GUI_ENABLE Then
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetData($Label3, "")
GUICtrlSetData($Input2, "")
EndIf
Else
If BitAND(GUICtrlGetState($Button1), $GUI_DISABLE) = $GUI_DISABLE Then
GUICtrlSetState($Button1, $GUI_ENABLE)
EndIf
If GUICtrlRead($Input1) <> $flag Then
GUICtrlSetData($Label3, GUICtrlRead($Input1))
GUICtrlSetData($Input2, GUICtrlRead($Input1))
$flag = GUICtrlRead($Input1)
EndIf
EndIf
WEnd 楼上的,真是太谢谢你了,但是还有一个小问题还没有得到解决,就是清空第二个框的时候按钮没变灰色!
能否帮忙再解决一下这个问题,真是万分感谢了! 谢谢9楼您帮忙,我已经测试成功了! 谢谢9楼{:face (396):}
页:
[1]