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. Same hotkey for different dialogs in the same MFC program ??

Same hotkey for different dialogs in the same MFC program ??

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionannouncement
5 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.
  • B Offline
    B Offline
    bjolletts
    wrote on last edited by
    #1

    Hi I have a MFC-dialog program with a list in it. I have assigned F5 as a hotkey to update the list through the RegisterHotKey function. This works fine But from the main window I want to open another dialog with a different list in it. I want to use F5 as a update-hotkey in this dialog too .. but I cant get it to work. F5 only updates the list in the main dialog. I thought that a RegisterHotKey registered a hotkey for the whole system so that I can capture it in every dialog in my program ?? Any help is much appreciated !

    D 1 Reply Last reply
    0
    • B bjolletts

      Hi I have a MFC-dialog program with a list in it. I have assigned F5 as a hotkey to update the list through the RegisterHotKey function. This works fine But from the main window I want to open another dialog with a different list in it. I want to use F5 as a update-hotkey in this dialog too .. but I cant get it to work. F5 only updates the list in the main dialog. I thought that a RegisterHotKey registered a hotkey for the whole system so that I can capture it in every dialog in my program ?? Any help is much appreciated !

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      How are you calling RegisterHotKey()?


      A rich person is not the one who has the most, but the one that needs the least.

      B 1 Reply Last reply
      0
      • D David Crow

        How are you calling RegisterHotKey()?


        A rich person is not the one who has the most, but the one that needs the least.

        B Offline
        B Offline
        bjolletts
        wrote on last edited by
        #3

        I do it like this: In the maindialogs OnInit-function: RegisterHotKey(GetSafeHwnd(), m_IDHotKey, NULL, VK_F5); And add this to the messagemap in every dialog that should use the hotkey: ON_MESSAGE(WM_HOTKEY,OnHotKey) And the OnHotKey function looks like this: LRESULT CFingerIDAdminDlg::OnHotKey(WPARAM wParam, LPARAM lParam) { // Do stuff } It only works for the main dialog ... a F5-keystroke in the child window registrates as a F5-key in the main window. I thought that the WM_HOTKEY-message was going to be handled by the dialog that is active ??

        D M 2 Replies Last reply
        0
        • B bjolletts

          I do it like this: In the maindialogs OnInit-function: RegisterHotKey(GetSafeHwnd(), m_IDHotKey, NULL, VK_F5); And add this to the messagemap in every dialog that should use the hotkey: ON_MESSAGE(WM_HOTKEY,OnHotKey) And the OnHotKey function looks like this: LRESULT CFingerIDAdminDlg::OnHotKey(WPARAM wParam, LPARAM lParam) { // Do stuff } It only works for the main dialog ... a F5-keystroke in the child window registrates as a F5-key in the main window. I thought that the WM_HOTKEY-message was going to be handled by the dialog that is active ??

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Have you used Spy++ to see the messages that are being received by both the main window and the child dialogs?


          A rich person is not the one who has the most, but the one that needs the least.

          1 Reply Last reply
          0
          • B bjolletts

            I do it like this: In the maindialogs OnInit-function: RegisterHotKey(GetSafeHwnd(), m_IDHotKey, NULL, VK_F5); And add this to the messagemap in every dialog that should use the hotkey: ON_MESSAGE(WM_HOTKEY,OnHotKey) And the OnHotKey function looks like this: LRESULT CFingerIDAdminDlg::OnHotKey(WPARAM wParam, LPARAM lParam) { // Do stuff } It only works for the main dialog ... a F5-keystroke in the child window registrates as a F5-key in the main window. I thought that the WM_HOTKEY-message was going to be handled by the dialog that is active ??

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            me think you need to put the handler in all the different dialogs ?


            Maximilien Lincourt Your Head A Splode - Strong Bad

            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