Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC: virtual keys and the "extended" bit

Status
Not open for further replies.

Rewbs

Programmer
May 1, 2002
18
GB
Hi all,

I'm trying to add keyboard customisation to my app. I need some help understanding the relation between virtual key codes the "extended" bit.

If a user associates numpad 3 with a command, my app will store the value VK_NUMPAD3 (0x63) against that command.
If a user associates page down with a command, my app will store the value VK_NEXT (0x22) against that command.
...
(See
So far so good. But when I try to display the string representing the key associated with each command, the VK_xxx value is not sufficient: I also need to know if the key is "extended" or not.
For example, when I use:
CHotKeyCtrl::GetKeyName(UINT virtualkey, bool extended)

I get the following output:
GetKeyName(VK_NUMPAD3, true) //returns PGDOWN
GetKeyName(VK_NUMPAD3, false) //returns NUM 3
GetKeyName(VK_NEXT, true)//returns PGDOWN
GetKeyName(VK_NEXT, false)//returns NUM 3

So here I'd like to use:
. GetKeyName(vkCode, true) if vkCode==VK_NEXT
. GetKeyName(vkCode, false) if vkCode==VK_NUMPAD3
To get the correct string every time, I would need to figure out whether I should to set "extended" for each possible value of vkCode. I don't understand why this is necessary, since the keycodes themselves are sufficient to be distinguished from each other.

To sum up, my questions are:
1. Why is knowledge of the extended bit necessary when calling CHotKeyCtrl::GetKeyName, given that the exact key is already identified by the keycode?
2. Is there a quick way to deduce the correct value of the extended bool based on the virtual key code? Does someone have a map of some sort? (extended = vkCode>0x60 ? false : true works to an extent but still doesn't get strings for all keypresses correct)
3. My understanding is that by using virtual key codes and CHotKeyCtrl::GetKeyName, I am catering for all keyboard layouts. Is this right?

Thanks in advance for any help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top