- Oct 10, 1999
- 1,370
- 1
- 0
I'm having a slight problem with virtual keys and I'm hoping if someone knows the solution.
I have a program that saves keystrokes by storing their virtual key values in an INI file. I get the virtual key from the WM_KEYDOWN message, and apart from storing them, the name of the key itself is displayed to the user using GetKeyNameText. So if I hit the Space Bar it'll save VK_SPACE to the config file and at the same time display "Space" in the dialog box.
The problem occurs when I try to do this with the extended keys Insert, Home, Page Up, Delete, etc.
The way WM_KEYDOWN works, lets say I press Insert, the message will return VK_NUMPAD0 in wParam and set the flag at bit 24 on lParam specifying that it is an extended key. This also happens with the other extended keys (e.g. Home will return VK_NUMPAD7, PgUp will return VK_NUMPAD9, etc).
How can I translate this into the proper virtual key (i.e. VK_INSERT instead of VK_NUMPAD7) without explicitly going through a switch/case statement and doing it manually? Or is there a better way, or a function that I can use to get my desired results?
Hope this all makes sense and thanks in advance.
atwl
I have a program that saves keystrokes by storing their virtual key values in an INI file. I get the virtual key from the WM_KEYDOWN message, and apart from storing them, the name of the key itself is displayed to the user using GetKeyNameText. So if I hit the Space Bar it'll save VK_SPACE to the config file and at the same time display "Space" in the dialog box.
The problem occurs when I try to do this with the extended keys Insert, Home, Page Up, Delete, etc.
The way WM_KEYDOWN works, lets say I press Insert, the message will return VK_NUMPAD0 in wParam and set the flag at bit 24 on lParam specifying that it is an extended key. This also happens with the other extended keys (e.g. Home will return VK_NUMPAD7, PgUp will return VK_NUMPAD9, etc).
How can I translate this into the proper virtual key (i.e. VK_INSERT instead of VK_NUMPAD7) without explicitly going through a switch/case statement and doing it manually? Or is there a better way, or a function that I can use to get my desired results?
Hope this all makes sense and thanks in advance.