Print Page | Close Window

CXTPControlEdit in CommandBar Accel bug

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=576
Printed Date: 15 May 2024 at 6:47pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPControlEdit in CommandBar Accel bug
Posted By: vladsch
Subject: CXTPControlEdit in CommandBar Accel bug
Date 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;
}

 




Replies:
Posted By: Oleg
Date Posted: 29 March 2004 at 12:22am
fixed.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net