回复 1# smooth #include <WindowsConstants.au3>
#include <EditConstants.au3>
Local $sDefault = "默认值"
GUICreate('TEST', 420, 200)
$Input = GUICtrlCreateInput($sDefault, 10, 15, 400, 23)
$Edit = GUICtrlCreateEdit('', 10, 50, 400, 140)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
Do
Until GUIGetMsg() == -3
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $nCode = BitShift($wParam, 16)
Local $ID = BitAND($wParam, 0x0000FFFF)
If $ID <> $Input Then Return
If $nCode = $EN_KILLFOCUS Then
If GUICtrlRead($Input) == '' Then GUICtrlSetData($Input, $sDefault)
ElseIf $nCode = $EN_SETFOCUS Then
GUICtrlSetData($Input, '')
EndIf
EndFunc
|