Link to home
Start Free TrialLog in
Avatar of kkuu
kkuu

asked on

Simple question about keyboard?

Hi All,

I have used the function PreTranslateMessage to check which
key is pressed by the user. But I don't know how to check the following keys (NUMPAD, ALT, SHIFT, ESCAPE, CTRL, etc)

BOOL CMyEditView::PreTranslateMessage(MSG* pMsg)
{
      if (pMsg->lParam=='SHIFT')
            AfxMessageBox("SHIFT PRESSED");
      if (pMsg->lParam=='CTRL')
            AfxMessageBox("CTRL PRESSED");
      if (pMsg->wParam=='9')
            AfxMessageBox("9 Pressed");

             // go to porcess another function when NUMPAD BUTTON NO 9 is pressed.....
             // when other buttons such as key ' 9', 'Shift+9', 'Ctrl+9' is pressed, nothing will be done
      return CFormView::PreTranslateMessage(pMsg);
}

Really, I only want to know whether the user had the NUMPAD Button only...I will not process my function when the user pressed key '9', 'Shift+9', 'Ctrl+9'. (the 9 here is the key not at the right hand side of the keyboard);
My function will only be processed when the user had pressed the Numpad button no.9.

How can I do this?

Thanks!!!
Avatar of kkuu
kkuu

ASKER

Edited text of question
open resourse Accelerator's IDR_MAINFRAME ,add your key in Accelerator's table
ASKER CERTIFIED SOLUTION
Avatar of jim_pettinato
jim_pettinato

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial