1. 程式人生 > >實時輸入框,相當於VB的change()事件

實時輸入框,相當於VB的change()事件

$Form1 = GUICreate("", 533, 464)

$Input_1 = GuiCtrlCreateInput("", 10, 20, 190, 30)

$Label_2 = GuiCtrlCreateLabel("", 220, 30, 130, 20)

Global Const $WM_COMMAND = 0x0111

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

GUISetState()

While 1

    $msg = GUIGetMsg()

    Select

        Case $msg = -3

            ExitLoop

        Case Else

            ;;;

    EndSelect

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 GUICtrlSetData($Label_2,GUICtrlRead($Input_1));此處是實時的結果

EndFunc   ;==>MY_WM_COMMAND