#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include "SendMessage.au3"
$Form1 = GUICreate("练习", 200, 150, -1, -1)
GUICtrlCreateLabel("小时数:", 5, 2)
GUICtrlCreateLabel("分钟数:", 5, 22)
$input = GUICtrlCreateInput("", 65, 2, 80, 15, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlSetLimit(-1, 2)
$input1 = GUICtrlCreateInput("", 65, 22, 80, 15, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlSetLimit(-1, 2)
$button = GUICtrlCreateButton("确定", 60, 40, 30, 20)
GUISetState()
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $button
$Rinput = GUICtrlRead($input)
$Rinput1 = GUICtrlRead($input1)
MsgBox(0, '你输入的时间', 'Enter the Number of hours : ' & $Rinput _
& @CRLF & 'Enter the Number of minutes : ' & $Rinput1 _
& @CRLF & 'Time : ' & $Rinput & ':' & $Rinput1)
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $iCode = BitShift($wParam, 16)
Switch $iCode
Case $EN_CHANGE
$TEXT=SENDMESS_GETTEXT($lParam)
Switch $lParam
Case GUICtrlGetHandle($input)
ToolTip("")
If $TEXT>23 Then
ToolTip("超限,自动置最大值23")
SENDMESS_SETTEXT($lParam,23)
EndIf
Case GUICtrlGetHandle($input1)
If $TEXT>59 Then SENDMESS_SETTEXT($lParam,59)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func SENDMESS_GETTEXT($hWnd)
Local $Len = _SendMessage($hWnd, 0x000E) + 1
Local $Buffer = DllStructCreate("wchar Text[" & $Len & "]")
_SendMessage($hWnd, 0x000D, $Len, $Buffer, 0, "wparam", "struct*")
Return DllStructGetData($Buffer, "Text")
EndFunc
Func SENDMESS_SETTEXT($hWnd,$sText)
_SendMessage($hWnd, 0x000C, 0, $sText, 0, "wparam", "wstr")
EndFunc
|