How to use F10 as a shortcut in an MFC application using a Ribbon

I developed an MFC application using VS2008 and the MFC featurepack. This application UI is using a ribbon.

I now need to have F10 as a proper shortcut for one of the critical feature of my application but I seem to be unable to set the accelerator correctly as it always use the default ribbon accelerator over mine.

Any idea how to achieve this ?

Answers


I assume you've already tried registering a hotkey. The canonical way to get at the keystroke is to use SetWindowsHookEx, for your app's main thread. Global windows hooks are loady, and the security restriction on hooking in Vista/Win7/Server 2008 have made them a lot less useful anyway. But a process-specific hook would be fine - and wouldn't need to be in a DLL.


Have you tried adding a handler for WM_SYSKEYDOWN and checking the message code for a wParam value of VK_F10? F10 needs special handling as it's the old alternative for pressing the Alt key to open the menu bar under keyboard control.


Had same problem and solved it by adding method: virtual BOOL PreTranslateMessage(MSG* pMsg);

BOOL CMyView::PreTranslateMessage(MSG* pMsg)
{
    if ((pMsg->message == WM_SYSKEYDOWN) && (pMsg->wParam == VK_F10))
    {
        OnMyAction(); //code on F10
        return TRUE;
    }
    return CView::PreTranslateMessage(pMsg);
}

Need Your Help

Java API for Semantic Similarity / Relatedness between two "WORDS"

java semantics similarity wordnet ws4j

i need to find out semantic similarity / relatedness between two input words. Following words are similar or related in real world:-