Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - How to: Ribbon Toolbars from CommandBars Designer
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to: Ribbon Toolbars from CommandBars Designer

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


Joined: 26 April 2010
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote lfoster Quote  Post ReplyReply Direct Link To This Post Topic: How to: Ribbon Toolbars from CommandBars Designer
    Posted: 08 June 2010 at 8:32am
I'm playing around with Ribbon toolbars that have been loaded in from CommandBars Designer projects and can currently switch between Ribbon bars at runtime which is nice. As I couldn't really find anything in the forum on how to do it I thought I'd post up my code to help others out. The sample applications only show how to load in from binary resources in your application but if like me you want to load different layouts at different times without having to recompile then the following will help.


CFile pFile(_T("res\\CamioMin.xcb"),CFile::modeRead);
CArchive ar1(&pFile,CArchive::load | CArchive::bNoFlushOnDelete);
pCommandBars->LoadDesignerBars(ar1);
ar1.Close();


The following brings my designer toolbars in for customisation, excellent :


void CMainFrame::ShowCustomizeDialog(int nSelectedPage)
{
     CXTPCustomizeSheet cs(GetCommandBars());
     CXTPCommandBars* pCommandBars = GetCommandBars();
     CXTPRibbonCustomizeQuickAccessPage pageQuickAccess(&cs);
     cs.AddPage(&pageQuickAccess);
     pageQuickAccess.AddCategories(pCommandBars->m_pDesignerControls);

     CXTPCustomizeKeyboardPage pageKeyboard(&cs);
     cs.AddPage(&pageKeyboard);     
     pageKeyboard.AddCategories(pCommandBars->m_pDesignerControls);

     CXTPCustomizeMenusPage pageMenus(&cs);
     cs.AddPage(&pageMenus);

     CXTPCustomizeOptionsPage pageOptions(&cs);
     cs.AddPage(&pageOptions);

     CXTPCustomizeCommandsPage* pCommands = cs.GetCommandsPage();
     pCommands->AddCategories(pCommandBars->m_pDesignerControls);

     cs.SetActivePage(nSelectedPage);

     cs.DoModal();
}


Just remember to export your resources from the CommandBars Designer so you can load them into your application. I Hope this helps some of those searching the forums.

Lewis
Back to Top
lfoster View Drop Down
Groupie
Groupie


Joined: 26 April 2010
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote lfoster Quote  Post ReplyReply Direct Link To This Post Posted: 09 June 2010 at 6:38am
We do seem to have a problem with different languages when using the CommandBars Designer .xcb files.

One solution is to translate the .xcb files but they don't appear to be valid xml according to our language processing tools. This also doesn't seem like the best solution. Ideally I'd like to stick with language "satallite" dlls but I'm struggling to see how this can be done as we essentially have no string tables, everything is in the .xcb file.

Has anyone got any experience with .xcb files from CommandBars Designer? Any ideas on how you could use language dlls?

I'll be sure to post up with any solution that I can work out.
Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 09 June 2010 at 9:57am
The language dlls only change built-in strings, it won't convert your text like the buttons you add.

You can use CommandBar Actions:

http://codejock.com/support/articles/com/commandbars/cb_26.asp

There is a MFC CommandBars Action sample to show how to use them
Back to Top
lfoster View Drop Down
Groupie
Groupie


Joined: 26 April 2010
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote lfoster Quote  Post ReplyReply Direct Link To This Post Posted: 09 June 2010 at 10:37am
Excellent I'll take a look, thanks SuperMario.
Back to Top
lfoster View Drop Down
Groupie
Groupie


Joined: 26 April 2010
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote lfoster Quote  Post ReplyReply Direct Link To This Post Posted: 09 June 2010 at 11:28am
Hmm, I see a few issues with actions.

1. It seems Ribbon groups do not have actions listed in the CommandBars Designer. It may be possible to create an action manually through XML and to give the group the same ID as the action? - Not ideal, but it may work, i will try it.

2. I see no way to export actions from CommandBars Designer to an XML format that the Resource Editor can understand. I have tried exporting to XML and to XCB but the CodeJock Resource Editor does not understand either because they contain bitmap information etc.

I can see how Actions can allow me to use multiple languages easily. I just can't see how to convert my .xcb file into a number of different language .xml files containing just the actions...

Thanks
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.