Click to See Complete Forum and Search --> : Keyboard event


Sean
June 4th, 1999, 12:22 AM
I want to execute a statement when a particular key is pressed. How do I do it?

Thank you,
Sean.

B. Colombet
June 4th, 1999, 03:32 AM
Use ClassWizard to get WM_KEYDOWN or WM_KEYUP messages.
The method OnKeyDown will be called each time a key is down.
Then you'll get the keycode.
Hope it helps.


C++ developer
Faculté de Médecine
27 Bd Jean Moulin
13385 Marseille cedex 05

ric
June 4th, 1999, 05:29 AM
if you want to hook before the key override the PreTranslateMessage() function like this:

int CDialog::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN
&& pMsg->wParam==desired_key)
{
\\ execute stament
}

return CDialog::PreTranslateMessage(pMsg);

}

}