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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Linking functions to keystrokes

Linking functions to keystrokes

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 1 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.
  • B Offline
    B Offline
    BoudewijnEctor
    wrote on last edited by
    #1

    Hi There, I've made a key accelerator table, and I've linked this one to my app. But how do I associate the message from the accelerator to a function? Is this also possible in a dialog based app? Thanks,

    M 1 Reply Last reply
    0
    • B BoudewijnEctor

      Hi There, I've made a key accelerator table, and I've linked this one to my app. But how do I associate the message from the accelerator to a function? Is this also possible in a dialog based app? Thanks,

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      A keyboard accelerator generates (through the ::TranslateAccelerator function) a WM_COMMAND message with the identifier you've assigned in the accelerator table. In MFC, CFrameWnd::PreTranslateMessage calls ::TranslateAccelerator for you. Handle the message with an ON_COMMAND macro. For a raw API application, you should add a call to TranslateAccelerator in your message loop and handle the message in your window's window procedure. For an MFC dialog-based application, override PreTranslateMessage and add a call to TranslateAccelerator. Again, handle with ON_COMMAND. Note that menu items, command buttons, toolbar buttons and accelerators all generate WM_COMMAND messages. You should assign all items in the above categories which perform the same operation the same identifier (e.g. ID_FILE_SAVE for the File > Save menu item, the Save button in the toolbar, and the Ctrl+S key combination).

      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