#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\my documents\form1.kxf
$Form1 = GUICreate("test", 409, 260, 434, 170)
$Label1 = GUICtrlCreateLabel("X:", 40, 32, 86, 17)
$Input1 = GUICtrlCreateInput("", 120, 32, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
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 $nNotifyCode = $EN_CHANGE Then
If GUICtrlRead($Input1) > 169 Then
$caretpos = _Caret_GetPos()
$pos=WinGetPos($Form1)
ToolTip("输入数据太大", $pos[0] + 120 + $caretpos[0], $pos[1] + 32 + $caretpos[1] + 21 * 2, "出错", 3, 3)
EndIf
EndIf
EndFunc ;==>MY_WM_COMMAND
Func _Caret_GetPos()
Local $POINT = DllStructCreate("long;long")
Local $Return[2]
DllCall("User32.dll", "int", "GetCaretPos", "ptr", DllStructGetPtr($POINT))
$Return[0] = DllStructGetData($POINT, 1)
$Return[1] = DllStructGetData($POINT, 2)
Return $Return
EndFunc ;==>_Caret_GetPos
|