GetMessages

can someone show me an example of how i can have my app get the WM_KEYPRESS, WM_KEYDOWN, WM_KEYPRESS messages from a TextBox?

and also if anyone knows a way that i can restrict all keys except 0-9 that would help too.

Comments

  • As far as the 0-9 keys.

    In the Key_Press event of that textbox:

    if isNumeric(chr(keyascii)) then
    0-9 was pressed
    else
    character key was pressed
    end if

    : can someone show me an example of how i can have my app get the WM_KEYPRESS, WM_KEYDOWN, WM_KEYPRESS messages from a TextBox?
    :
    : and also if anyone knows a way that i can restrict all keys except 0-9 that would help too.
    :

  • : can someone show me an example of how i can have my app get the WM_KEYPRESS, WM_KEYDOWN, WM_KEYPRESS messages from a TextBox?
    :
    : and also if anyone knows a way that i can restrict all keys except 0-9 that would help too.
    :

    That depends on whether or not you actually want the messages. If you do, use subclassing (check the net, there's a billion examples out there). Otherwise, WM_KEYDOWN relates to the _KeyDown event, WM_KEYUP to the _KeyUp event and WM_KEYPRESS to _KeyPress.

    Check in the KeyDown/KeyPress events and set KeyCode/KeyAscii to 0 if it's a dissallowed key.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories