回复 3# fenhanxue
理論上 輸入密碼 不會有人打快的吧 打快了 不就等同 不顯示 一樣的意思
我覺得你的做法效果不錯了
我本來的意思是 如下的範例
從 MY_WM_COMMAND 去改 就好
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 629, 106, 192, 132)
$Input1 = GUICtrlCreateInput("Input1", 40, 32, 433, 24)
$Button1 = GUICtrlCreateButton("Button1", 496, 32, 105, 33)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($Input1, '')
EndSwitch
WEnd
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local Const $EN_CHANGE = 0x300
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0xFFFF)
Local $hCtrl = $lParam
If $nID = $Input1 Then
If $nNotifyCode = $EN_CHANGE Then
$read=GUICtrlRead($Input1)
If String(StringLeft($read,1))=="0" Or String(StringLeft($read,1))=="." Then
GUICtrlSetData($Input1,StringRegExpReplace($read,'^0+|^\.+',''))
Else
$write=StringRegExpReplace($read,'[^\.0-9]+','')
$temp=StringSplit($write,".",1+2)
if UBound($temp)>2 Then $write=$temp[0]&"."&$temp[1]
GUICtrlSetData($Input1,$write)
EndIf
EndIf
EndIf
EndFunc
|