Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. PreTranslateMessage does not handle F1 and F12

PreTranslateMessage does not handle F1 and F12

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    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?

    J J 2 Replies Last reply
    0
    • J justin223

      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?

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      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 override OnHelpInfo 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

      J 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        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 override OnHelpInfo 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

        J Offline
        J Offline
        justin223
        wrote on last edited by
        #3

        You 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

        1 Reply Last reply
        0
        • J justin223

          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?

          J Offline
          J Offline
          Joan M
          wrote on last edited by
          #4

          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...

          https://www.robotecnik.com freelance robots, PLC and CNC programmer.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups