I want to execute a statement when a particular key is pressed. How do I do it?
Thank you,
Sean.
Printable View
I want to execute a statement when a particular key is pressed. How do I do it?
Thank you,
Sean.
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
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);
}
}