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