The current implementation of the command bars does not pre-translate messages that are needed by the CEdit control in a CXTPControlEdit. This bug applies to all CEdit controls in toolbars and menus, including the Caption edit box in the customize menu mode.
The problem arises if the keys used by CEdit (left, right, backspace, delete, Ctrl-z, Ctrl-y, etc.) are mapped to command IDs in the accelerator table for use by the application. These commands are translated and passed to CEdit which ignores them.
To duplicate the bug, modify the CustomThemes sample by adding entries to the Accelerator table in resources for the Return, Backspace or any other keys used by an Edit box during editing. Run the application, click on the edit box in the command bar and try to use the mapped edit keys. Keys will be ignored.
The solution is to add the following code to CXTPCommandBars::PreTranslateFrameMessage(MSG* pMsg) which will bypass the application accelerator table when a CEdit control has focus:
BOOL CXTPCommandBars::PreTranslateFrameMessage(MSG* pMsg) { if (!XTPMouseManager()->IsMouseLocked() && !XTPMouseManager()->IsTrackedLock(0)) { . . . // omitted for brevity . . . }
// see if the current control is an edit box if (((pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) && (pMsg->wParam != VK_RETURN && pMsg->wParam != VK_TAB)) || pMsg->message == WM_CHAR ) { CWnd* pWnd = CWnd::GetFocus(); if (pWnd && pWnd->IsKindOf(RUNTIME_CLASS(CXTPEdit))) { TranslateMessage(pMsg); DispatchMessage(pMsg); return TRUE; } }
. . . // omitted for brevity . . . return nReturn; }
|
|