right or left control-key ???
-
I am about to write a dll that allows users to define keys (e. g. for a game), but I cannot distinguish between the right and left ctrl-key. In the second parameter the WM_KEYDOWN-Message gives me this information in a DWORD-value (LPARAM), but I am not able to decode the information. How can I get this done? Thank you.
-
I am about to write a dll that allows users to define keys (e. g. for a game), but I cannot distinguish between the right and left ctrl-key. In the second parameter the WM_KEYDOWN-Message gives me this information in a DWORD-value (LPARAM), but I am not able to decode the information. How can I get this done? Thank you.
-
the right key (extended key) is pressed if bit 24 of lParam is set. so use the bitwise AND operator (&) to check that bit.
if (lParam & 0x01000000)
{
// An extended key
}:)
-
Thank you. :-) Your tip works. But one question remains: When I read "bit 24 of lParam", how do I get the binary code like "01000000" ? :confused:
0x01000000 is not a binary code, it is a hexadecimal number (note the '0x'). Each digit in a hexadecimal number represents four bits.
Hexadecimal Digital Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111So when we say bit 24 is set we get this
bit 33 2 2 1 1
number 1098 7654 3210 9876 5432 1098 7654 3210
| | | | | | |
binary 0000 0001 0000 0000 0000 0000 0000 0000hex 0 1 0 0 0 0 0 0
Also look up bitwise operators in MSDN
-
0x01000000 is not a binary code, it is a hexadecimal number (note the '0x'). Each digit in a hexadecimal number represents four bits.
Hexadecimal Digital Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111So when we say bit 24 is set we get this
bit 33 2 2 1 1
number 1098 7654 3210 9876 5432 1098 7654 3210
| | | | | | |
binary 0000 0001 0000 0000 0000 0000 0000 0000hex 0 1 0 0 0 0 0 0
Also look up bitwise operators in MSDN
I don't have any concern on this stuff, but I want to say that you are very kind to do this! Honestly I didn't ever tried to explain in detail in helping others although I've got tons of information from others like you. Sincerely I honor your work. Regards, Ryan
-
I don't have any concern on this stuff, but I want to say that you are very kind to do this! Honestly I didn't ever tried to explain in detail in helping others although I've got tons of information from others like you. Sincerely I honor your work. Regards, Ryan