-
WM_KEYDOWN and VK_ESCAPE
Hey.
Anyone know why I might not be recieving WM_KEYDOWN or WM_CHAR messages when I press the escape key? Even with completely stripped down windows procedure (i.e. only processing the WM_KEYDOWN and WM_DESTROY messages, I am having the same problem. Also - I can get a WM_KEYUP message.. WTF?
Code:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_KEYDOWN:
{
OutputDebugString(TEXT("WM_KEYDOWN\n"));
}
return 0;
case WM_KEYUP:
{
OutputDebugString(TEXT("WM_KEYUP\n"));
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
-
Goddam it. It has something to do with IsDialogMessage - does anyone know what this does with the WM_CHAR and WM_KEYDOWN messages? I can't seem to find it documented anywhere..
-
A rough idea of how a winapi function is implemented can sometimes be obtained from the WINE version. Here is the identifier search page and here is the code for IsDialogMessageW.
-
>>It has something to do with IsDialogMessage<<
The ESC key, like the TAB key, is one of the keys for which IsDialogMessage provides default keyboard handling: it's sent as a command notification with an id of IDCANCEL. For example,
Code:
case WM_COMMAND:
{
if (LOWORD(wParam)==IDCANCEL)
{
/* ESC key has been pressed*/
}
}
will trap the ESC keypress.
-
Thanks for that - I was wondering what was going on - particularly since I was getting WM_KEYUP messages.