Force menu item shortcut key text without accelerator (VC9/MFC
Feature Pack)
We are converting an app to VC9 and incorporating the MFC Feature
Pack. We use an accelerator table as well as PreTranslateMessage to
handle keyboard shortcuts (PreTranslateMessage is used as some
shortcuts do not contain standard Windows modifier keys required for
accelerator table entries).
Menu items contain hard coded shortcut strings using the standard '\t'
expression to denote the right justified keyboard shortcut in the menu
e.g.:
"&Open...\tCtrl+O"
The problem is that this shortcut text is now ignored by the framework
at runtime and keyboard shortcuts are instead shown against a given
menu item ONLY when there is an accelerator table entry for the menu
item ID.
This would be a useful feature were it not for our need to incorporate
PreTranslateMessage shortcut handling.
Efforts to override the text using CCmdUI SetText have no effect e.g.:
void CMainFrame::OnUpdateDoSomething(CCmdUI* pCmdUI)
{
// Everything after and including the =91\t' is ignored at runtime
pCmdUI->SetText("&Do Something\tShift+Delete");
}
Is there any way to prevent hard coded menu item text being overridden
in this way? The only solution we've found thus far is to drop or
substitute the =91\t' in the menu item text, but this means that
shortcut keys are no longer properly aligned in menu items.
Thanks in advance for any suggestions.