PreTranslateMessage does not handle F1 and F12
-
Im using PreTranslateMessage to fetch all keystrokes that are made in a dialog. And I return TRUE, just as I should, for each message that I handle. Everything works, except for F1, F12 and the windowskeys. I recieve the F1 and F12 keystrokes and return TRUE, but they seem to get handled by the application anyway. F1 launches help, F12 closes the dialog. How do I resolve this issue?
-
Im using PreTranslateMessage to fetch all keystrokes that are made in a dialog. And I return TRUE, just as I should, for each message that I handle. Everything works, except for F1, F12 and the windowskeys. I recieve the F1 and F12 keystrokes and return TRUE, but they seem to get handled by the application anyway. F1 launches help, F12 closes the dialog. How do I resolve this issue?
I've had the same problem recently. Seems like the MFC framework insists on handling F1 even if the
PreTranslateMessage
tells otherwise. The solution is to overrideOnHelpInfo
and do nothing there. As for F12, my app activates the debugger as though a user breakpoint had been called, but this does not happen when executing the app in non-debug mode (CTRL+F5), so basically I did not investigate the issue further. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
I've had the same problem recently. Seems like the MFC framework insists on handling F1 even if the
PreTranslateMessage
tells otherwise. The solution is to overrideOnHelpInfo
and do nothing there. As for F12, my app activates the debugger as though a user breakpoint had been called, but this does not happen when executing the app in non-debug mode (CTRL+F5), so basically I did not investigate the issue further. Joaquín M López Muñoz Telefónica, Investigación y DesarrolloYou do not need to override OnHelpInfo. Add this in PreTranslateMessage // Magical mystical MFC F1 Help msg! if(pMsg->message == 0x4d) { gLog.WriteLogfile("help"); return(TRUE); // Eat it } Got it from this article: http://www.codeproject.com/winhelp/mfchelp.asp
-
Im using PreTranslateMessage to fetch all keystrokes that are made in a dialog. And I return TRUE, just as I should, for each message that I handle. Everything works, except for F1, F12 and the windowskeys. I recieve the F1 and F12 keystrokes and return TRUE, but they seem to get handled by the application anyway. F1 launches help, F12 closes the dialog. How do I resolve this issue?
Why don't you use a keyboard hook in order to prevent those keys to be used? windows keys can only be disabled (or handled in other way than the original one) by using a keyboard hook. It's easier than it seems and it allows you to handle all the keys you want once you have the main hook structure done. Hope this helps...