How to: Ribbon Toolbars from CommandBars Designer
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=16803
Printed Date: 22 November 2024 at 1:33pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: How to: Ribbon Toolbars from CommandBars Designer
Posted By: lfoster
Subject: How to: Ribbon Toolbars from CommandBars Designer
Date 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
|
Replies:
Posted By: lfoster
Date 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.
|
Posted By: SuperMario
Date 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
|
Posted By: lfoster
Date Posted: 09 June 2010 at 10:37am
Excellent I'll take a look, thanks SuperMario.
|
Posted By: lfoster
Date 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
|
|