-
LPARAM with WM_CHAR
Ok, I've been looking at a tutorial for keyboard input... and at the end, it says this:
Code:
This following is the BIT values breakdown of the 32-bit LPARAM -- Be sure to check
MSDN for any changes
0 - 15 Specifies the repeat count for the current message. The value is the number of
times the keystroke is auto-repeated as a result of the user holding down the key
16 - 23 Specifies the scan code. The value depends on the original equipment
manufacturer (OEM)
24 Specifies whether the key is an extended key, such as the right-hand alt and
ctrl keys that appear on an enhanced 101-key or 102-key keyboard. The value is 1
if it is an extended key otherwise it's 0
25 - 28 Reserved
29 The context code. The value is 1 if the alt key is held down while
the key is pressed otherwise it's 0
30 The previous key state. The value is 1 if the key is down
before the message is sent, or it is 0 if the key is up
31 The transition state. The value is 1 if the key is being released,
or it's 0 if the key is being pressed
The only thing I really need from the LPARAM is the last part, about the key being pressed/released, but how do I get its value? (I mean, do I typecast to a bool or something, or use some macro?)
-
all you need to look at is WPARAM as it contains the key code of the character that was pressed.
Code:
if(wParam == 'A')
{
// A/a was pressed
}
hope this helps
U.
-
:( I got that far, but I want to be able to figure out when the key is released. I actually started out trying to use WM_KEYDOWN/KEYUP, but I couldn't figure out how the virtual-key codes worked. Then I looked at WM_CHAR and it has that flag thingee telling if the message was generated because the key was being pressed or released... I tried doing this:
Code:
bool* test = (bool*)&lParam;
if(test[31] == 0)
(...)
It didn't bomb, but when the message was generated, test[31] was always 0.
Do you know how I might find out what key it is when a WM_KEYDOWN message pops up?
-
yeah.. for keys a-z and A-Z they are the same as the actual ascii for uppercase chars.
so when you can the WM_KEYUP/DOWN messages... test for 'A', 'B', 'C' etc.... all the other keys have a VK_* constant ...that should get you going...
good luck!
U.
-
Ahhhh, it has to be uppercase eh? That would explain a lot. I kept trying lowercase :(
-
your welcome! :mad:
manners will get you more help in the future mate.
-
Oh, I forgot - thanks! (I thought I usually say thanks anyways?... oh well.) :D
-