#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