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. How to Change Shot-Cut Key of F1

How to Change Shot-Cut Key of F1

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
3 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.
  • L Offline
    L Offline
    louis 0
    wrote on last edited by
    #1

    In MFC help file, there is a paragrah: "The application’s accelerator table defines F1 for ID_HELP and SHIFT+F1 for ID_CONTEXT_HELP. You can change the keys used for these help functions by using Visual C++ to change the key values in the accelerator table." I try to define the F1 key for some function in my project (it's interface needs all the keys F1 to F12). I define a new volue for ID_HELP. But when I hit the F1 key, my application activates my function and the Windows help file Does anybody know how to fix this problem? I do not want to remove the Windows help F1 key. Just want to change it to another name, say ALT+F1 Thank You Very Much! Louis :confused:

    R S 2 Replies Last reply
    0
    • L louis 0

      In MFC help file, there is a paragrah: "The application’s accelerator table defines F1 for ID_HELP and SHIFT+F1 for ID_CONTEXT_HELP. You can change the keys used for these help functions by using Visual C++ to change the key values in the accelerator table." I try to define the F1 key for some function in my project (it's interface needs all the keys F1 to F12). I define a new volue for ID_HELP. But when I hit the F1 key, my application activates my function and the Windows help file Does anybody know how to fix this problem? I do not want to remove the Windows help F1 key. Just want to change it to another name, say ALT+F1 Thank You Very Much! Louis :confused:

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      A quick search of the MFC code shows that in the AFX function IsHelpKey, the system checks directly for F1. This function is only called in the default threadcore code (i think - not absolutely sure) when processing messages. My suggestion to get this to work for you would be to override the PreTranslateMessage function for the windows you need to use the F1 key for. Trap the F1 key yourself and then act on it directly to call the right code at that point yourself. To continue to get he help code to work for a different key, define an accellerator for e.g. Ctrl-H to map to ID_HELP command. Some code written from memory that may help.

      BOOL CMyWindow::PreTranslateMessage(MSG* pMsg)
      {
      if (pMSG->message == WM_KEYDOWN && pMsg->wParam == VK_F1)
      {
      // call my special function
      return TRUE ;
      }
      return CBaseWindow::PreTranslateMessage(pMsg) ;
      }

      Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool? Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge

      1 Reply Last reply
      0
      • L louis 0

        In MFC help file, there is a paragrah: "The application’s accelerator table defines F1 for ID_HELP and SHIFT+F1 for ID_CONTEXT_HELP. You can change the keys used for these help functions by using Visual C++ to change the key values in the accelerator table." I try to define the F1 key for some function in my project (it's interface needs all the keys F1 to F12). I define a new volue for ID_HELP. But when I hit the F1 key, my application activates my function and the Windows help file Does anybody know how to fix this problem? I do not want to remove the Windows help F1 key. Just want to change it to another name, say ALT+F1 Thank You Very Much! Louis :confused:

        S Offline
        S Offline
        Steen Krogsgaard
        wrote on last edited by
        #3

        This is no solution to your problem as Roger has already given one. What I'd like to do is recommend that you do not redefine the keys that have "standard" functionality in Win32 programs (e.g. F1, Alt-F4, F10). This will only confuse your user and make them think your program is complicated to use. Cheers Steen. "To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"

        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