Reputation: 40859
Say I have a large application frame in which I want default input to be a particular, central widget in that frame. If a key, like delete or escape, is pressed:
In WX I was able to do this with the escape key by overriding ProcessEvent within the application. I then told the application base to try dealing with it (which would send the event to the control for attempted processing) and if it didn't I would send it to the right widget.
I can't seem to find a correlary within MFC. It seems that character events never get sent up the window tree to the parents or to the application. What can I do?
Upvotes: 0
Views: 396
Reputation: 2493
You should be able to intercept all WM_KEYDOWN
messages by overriding CWinApp::PreTranslateMessage
in your CWinApp derived class.
Example:
BOOL CMyApp::PreTranslateMessage(MSG* pMsg)
{
if ( pMsg->message == WM_KEYDOWN ) {
// Do something special with this message
}
return CWinApp::PreTranslateMessage(pMsg);
}
Upvotes: 1