I was trying to use the following code to listen to simple keyboard events in a dialog based application, but nothing is happening on pressing these keys. Can somebody tell me what went wrong ?
BOOL PreTranslateMessage(MSG *pMsg)
{
CListeningApp* App = (CListeningApp*) AfxGetApp();
int x=(int)pMsg->wParam;
if(pMsg->message==WM_KEYDOWN)
{
if(x==VK_UP)
MessageBox(NULL,L"UP",L"UP", MB_OK);
if(x==VK_DOWN)
MessageBox(NULL,L"DOWN",L"DOWN", MB_OK);
if(x==VK_RIGHT)
MessageBox(NULL,L"RIGHT",L"RIGHT", MB_OK);
if(x==VK_LEFT)
MessageBox(NULL,L"LEFT",L"LEFT", MB_OK);
if(x==65)
MessageBox(NULL,L"Keyboard Event",L"You Pressed the letter a", MB_OK);
}
return TRUE;
}