Print Page | Close Window

Where are the accelerators?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2764
Printed Date: 08 November 2025 at 7:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Where are the accelerators?
Posted By: robosport
Subject: Where are the accelerators?
Date Posted: 22 August 2005 at 4:09pm

When I create an interface in the Command Bar Designer I add many keyboard accelerators. They show up on the menus when looking at the proejct in the command bar designer.

When I load the interface into my application's main frame using LoadDesignerBars( ar ) the UI looks correct, and all of the defined IDs are there and work fine, but none of my custom accelerators show up on the menus.

Any clue as to what am I forgetting to do?

Thanks.




Replies:
Posted By: Oleg
Date Posted: 23 August 2005 at 12:00am

So you use it in MFC project? Where you call LoadDesignerBars?



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


Posted By: robosport
Date Posted: 23 August 2005 at 12:10am

Yes, MFC.

BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
    if (!CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, pParentWnd, pContext))
        return FALSE;

    GenerateCommandBars();

    LoadCommandBars(lpProfile);

    XTPShortcutManager()->LoadShortcuts(this, lpProfile);

    return TRUE;
}

calls...

void CMainFrame::GenerateCommandBars()
{
    CXTPCommandBars* pCommandBars = GetCommandBars();
    pCommandBars->SetMenu( _T("Menu Bar"), 0);

    HRSRC hRsrs = FindResource(AfxGetInstanceHandle(),
        MAKEINTRESOURCE(IDR_COMMAND_BARS_V2), _T("COMMAND_BAR_DATA"));

    ASSERT(hRsrs);

    if (hRsrs)
    {
        HGLOBAL hGlobal = LoadResource(AfxGetInstanceHandle(), hRsrs);

        if (hGlobal)
        {
             DWORD dwSize = SizeofResource(AfxGetInstanceHandle(), hRsrs);

             LPVOID pData = LockResource(hGlobal);

             CMemFile file((BYTE*)pData, dwSize);

             CArchive ar(&file, CArchive::load | CArchive::bNoFlushOnDelete);

             pCommandBars->LoadDesignerBars(ar);

             XTAuxData().InitResources(AfxGetInstanceHandle());
        }
    }
}

Thanks.



Posted By: robosport
Date Posted: 23 August 2005 at 1:56am

Oleg, you always know exactly what to ask to help me find my own bugs. I noticed when pasting the above code into the reply that I had a leftover call to:

XTPShortcutManager()->LoadShortcuts(this, lpProfile);

...which overrides the accelerators in the designer resource with whatever is in the registry. I removed that line and everything works as expected now.

Thanks! 



Posted By: Oleg
Date Posted: 23 August 2005 at 6:46am

hmm...

removing this line you don't allow users to customize shortcuts... (if allowed)

if you allow to customize shortcuts, try to restore this line and delete old registry settings.



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


Posted By: robosport
Date Posted: 23 August 2005 at 6:50am

Thanks for the information. I don't currently support customizing shortcuts but when I add that functionality I'll remember to put this back in.

So are you saying that the old registry settings for the shortcuts were overriding the command bar designer shortcuts, and if I was running this app for the first time on a new computer the shortcuts should work even with this line in the code?

Thanks again.




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