Problem catching numpad keystrokes

Hello
Im wanting to use my numpad as direction north,east,south,west ect and have all other alpha/numbers work for text display.
So far i have experimented with wm-keydown and wm-char and found the later to be the best for handling the text output but its no good for catching the numpad keys as tranlatemessage converts them to the number vk codes.
I can catch the numpad entries with wm-keydown but then translatemessage sends it on to wm-char which is not what i want.
Is there a way to stop the key stroke being processed further after i have caught it in wm-keydown?.
Maybe im going about this all wrong, i have googled for the last few days on the subject with no luck.
I have been using wParam but wondering if i should be try lParam to better define what key was pressed.

Im using Dev-C++
You need to check the message after calling GetMessage. Only call TranslateMessage if it's not one you want translated. That's how MFC implements PreTranslateMessage.
Thank you kbw this is what i come up with

1
2
3
4
while (GetMessage (&messages, NULL, 0, 0) > 0)
    {
        if (DispatchMessage(&messages) != 1) TranslateMessage(&messages);
    }


All keystrokes successfully handled in WM_KEYDOWN return 1 and everything else is translated.

I was thinking more (from memory):
1
2
3
4
5
6
7
8
9
while (GetMessage(&msg, 0, 0, 0))
{
    if (PreTranslateMessage(&msg))
    {
        TranslateMessage(&msg);
    }

    DispatchMessage(&msg);
}


Then you can put your check in PreTranslateMessage.
Last edited on
Topic archived. No new replies allowed.