Advertisement

VK_0 - VK_9 won't work!

Started by September 01, 2000 08:28 PM
3 comments, last by Mike00 24 years, 2 months ago
Most of the VKs work except those 10.... Anyone know why? Thanks!
VK_0 - VK_9 and VK_A - VK_Z do not WORK, because they do not exist. For some unknown reason Microsoft decided that since VK_0 maps directly to the ASCII ''0'' and VK_A to ''A'', that you can just as easily use those constants directly instead of the VK_ style definitions. I found this out only a few months ago (when i switched from translated to untranslated keyboard messages) and still find it very strange that they choose not to include the simply defines in their SDK header files. BTW, you can simply create a header file yourself using a simple #ifndef / #define / #endif structure, that way you can use consistent VK_ switch cases. Good luck
Advertisement
Oh yeah, just for those who may not understand the issue. Some of Microsofts examples DO use VK_0 and VK_A etc... and the header file "winuser.h" included with Visual C++ 6 actually contains a comment stating the solution I posted above.

[for those curious, the way I found how to use VK_0 was to do a find-in-files search on the VC include directory for it - this trick is helpfull with very many SDK or C++ programming issues]

happy hunting
Thanks
I dont know if you are still searching for a solution to your problem.

You can use these standard API functions (GetKeyState() and VkKeyScan() )

#define KEYDOWN(vkey) ((GetKeyState(vkey)>>15))

#define CHDOWN(ch) (KEYDOWN(VkKeyScan(ch)))


So you can use KEYDOWN() for virtual keys (like VK_SHIFT, VK_UP,...) and use CHDOWN() for ASCII characters (like '0', 'a',...)
If the key is pressed they returns 1 (TRUE) else 0 (FALSE).


Edited by - Andrea on September 2, 2000 6:25:32 PM
IpSeDiXiT

This topic is closed to new replies.

Advertisement