Help with WM_KEYDOWN

Help,
I Can't Get the WM_KEYDOWN handler, using OnKeyDown to work in a dialog base application.

The program never runs OnKeyDown, when a key is pressed.
 
Eric
EricsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
galkinConnect With a Mentor Commented:
You cannot handle WM_KEYDOWN message in Dialog based applications. Istaed, overwrite your CDialog derived class' PreTranslateMessage function and check whether message filad of pMsg structure is WM_KEYDOWN
BOOL CYourDialog::PreTranslateMessage( MSG* pMsg )
{
if(pMsg->message == WM_KEYDOWN)
{
 // do whatever you want
return TRUE; // important!!!, do not call base class             //implementation in this case
}

return CDialog::PreTranslateMessage( pMsg );

}

0
 
EricsAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.