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. Using Alt key in Windows app?

Using Alt key in Windows app?

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

    I'm working on a Win32 (actually, Qt) app, and would like to use the alt key to modify some keyboard/mouse buttons. It's working great, except that pressing the alt key moves the keyboard focus to the menu (like it normally should). How can I disable/avoid that? Most importantly, is there a simple solution, without having to manually process messages? Thanks!

    J 1 Reply Last reply
    0
    • I IGx89

      I'm working on a Win32 (actually, Qt) app, and would like to use the alt key to modify some keyboard/mouse buttons. It's working great, except that pressing the alt key moves the keyboard focus to the menu (like it normally should). How can I disable/avoid that? Most importantly, is there a simple solution, without having to manually process messages? Thanks!

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      I don't think there's an easy solution. Especially not so with Qt, as it probably hides the message pump from you. I tried this in MFC:

      BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
      {
      if((pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP)
      && pMsg->wParam == VK_MENU) {
      DoMything();
      return TRUE;
      }

      return CFrameWnd::PreTranslateMessage(pMsg);
      }

      and it worked fairly well I believe. It didn't mess with the accelerators (ALT-F for File Menu, ALT-F4 for close application, etc), but it allowed me to do whatever I want to with the ALT-button. In this case I'm just filtering it out. If it's possible to implement a PreTranslateMessage() function in Qt, it's not a hard problem. Good luck. :) -- Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr. Welle: Erdball - F104-G Starfighter

      I 1 Reply Last reply
      0
      • J Jorgen Sigvardsson

        I don't think there's an easy solution. Especially not so with Qt, as it probably hides the message pump from you. I tried this in MFC:

        BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
        {
        if((pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP)
        && pMsg->wParam == VK_MENU) {
        DoMything();
        return TRUE;
        }

        return CFrameWnd::PreTranslateMessage(pMsg);
        }

        and it worked fairly well I believe. It didn't mess with the accelerators (ALT-F for File Menu, ALT-F4 for close application, etc), but it allowed me to do whatever I want to with the ALT-button. In this case I'm just filtering it out. If it's possible to implement a PreTranslateMessage() function in Qt, it's not a hard problem. Good luck. :) -- Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr. Welle: Erdball - F104-G Starfighter

        I Offline
        I Offline
        IGx89
        wrote on last edited by
        #3

        Thanks! Qt does have its own version of PreTranslateMessage, and I implemented it like so: if(pMsg->message == WM_SYSKEYUP && pMsg->wParam == VK_MENU && bIgnoreNextMenuKey) return true;

        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