Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Where are the accelerators?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Where are the accelerators?

 Post Reply Post Reply
Author
Message
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post Topic: Where are the accelerators?
    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.



Edited by robosport
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 23 August 2005 at 12:00am

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

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post 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! 

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 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
Back to Top
robosport View Drop Down
Groupie
Groupie


Joined: 20 June 2005
Location: United States
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote robosport Quote  Post ReplyReply Direct Link To This Post 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.

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.031 seconds.