This topic is now archived and is closed to further replies.

Jesper T

Win32, keyboard/virtual keys -problem

Recommended Posts

I need to convert virtual key codes into text strings, so instead of making a huge switch statement I decided to try some already existing functions: char keyName[48]; GetKeyNameText(MapVirtualKey(VK_SPACE, 0) >> 16, keyName, 48) The 16th to 23rd bit of the first parameter of GetKeyName() is the scan code, and MapVirtualKey() returns the scan code. This is the problem: GetKeyNameText returns zero (which means it has failed), and GetLastError also returns zero, which means that the last function was succesful. And nothing is added into the string. So whats going on here? any clues? [edited by - Jesper T on October 7, 2003 3:17:50 PM]

Share this post

Link to post
Share on other sites
Ah, yes, I read that too, but also


The function interprets the following portions of lParam:

Bits 16–23: Scan code.

Bit 24: Extended-key flag. Distinguishes some keys on an enhanced keyboard.

Bit 25: "Don't care" bit. The application calling this function sets this bit to indicate that the function should not distinguish between left and right CTRL and SHIFT keys, for example.

EDIT: NM, I found out whats wrong, I was shifting it the wrong way.. doh!

[edited by - Jesper T on October 8, 2003 6:49:29 AM]

Share this post

Link to post
Share on other sites