Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CXTPControlEdit in CommandBar Accel bug
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPControlEdit in CommandBar Accel bug

 Post Reply Post Reply
Author
Message
vladsch View Drop Down
Newbie
Newbie


Joined: 04 February 2004
Location: Canada
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote vladsch Quote  Post ReplyReply Direct Link To This Post Topic: CXTPControlEdit in CommandBar Accel bug
    Posted: 28 March 2004 at 10:26am

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;
}

 



Edited by vladsch
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 29 March 2004 at 12:22am
fixed.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.