Reputation: 986
I'm trying get extended key state
WNDPROC lpfnEditWndProc;
//edit - hwnd of edit control
lpfnEditWndProc = (WNDPROC) SetWindowLong(edit, GWL_WNDPROC, (DWORD) SubClassProc);
struct Bits {
WORD nRepeatCount: 16;
BYTE nScanCode : 8;
BYTE nExtended : 1;
BYTE nReserved : 4;
BYTE nContext : 1;
BYTE nPrevious : 1;
BYTE nTransition : 1;
};
union KeyInfo
{
LPARAM lParam;
Bits bits;
};
LRESULT CALLBACK SubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_CHAR:
{
KeyInfo v;
v.lParam = lParam;
printf("nExtended = %d\n", v.bits.nExtended);
}
break;
}
return CallWindowProc(lpfnEditWndProc, hwnd, msg, wParam, lParam);
}
nExtended always == 0
I tried to turn out information in the different ways, like (lParam << 24) & 1;
all the same nExtended == 0
Win7 64 bit, Visual Studio 2010
Upvotes: 0
Views: 933
Reputation: 612854
The documentation for WM_CHAR says:
Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lParam parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message.
You will have to process the WM_KEYDOWN and WM_KEYUP messages to get extended key information.
Upvotes: 2