MFC: virtualkeys and the "extended" bit
Posted: Sat Jun 12, 2004 5:08 am
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 http://msdn.microsoft.com/library/d...ualKeyCodes.asp)
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.
Archived topic from Iceteks, old topic ID:2414, old post ID:20438
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 http://msdn.microsoft.com/library/d...ualKeyCodes.asp)
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.
Archived topic from Iceteks, old topic ID:2414, old post ID:20438