Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Ribbon bar group from toolbar? Collapse All
Subject Author Date
Robert Webb Jul 14, 2008 - 8:38 PM

Hi,


I just asked in the general forum about populating a ribbon bar group from a toolbar, but I’d also like to know how to pull an individual button out of a toolbar resource for use on a ribbon bar button.  Any ideas?  Any sample code?


Thanks,

Rob.

Robert Webb Aug 28, 2008 - 7:13 PM

Sorry, maybe I didn’t explain myself very well.  Currently I have toolbars.  I want to move to a ribbon bar.  There are two issues:


(1) To get something up and running quickly I’d like a way to automatically fill ribbon groups with buttons from existing toolbar resources, rather than manually writing the code to create all those buttons separately.  The new MFC 9 feature pack provides this functionality (as does BCG and CodeJock).  They allow the buttons to wrap at points where there were separators in the original toolbar too.



(2) Also, my button images are all in strips, as required for toolbars, and we may allow the user to choose between ribbon bar and menu/toolbar styles, so I’d like to keep them that way.  Thus when adding buttons to a ribbon bar, I’d like to be able to pull their images out of these strips rather than splitting all those strips into separate bitmaps.  Is there a convenient way to do this?



Thanks,

Rob.

Technical Support Sep 1, 2008 - 11:14 AM

We could add some functions for loading ribbon pages from toolbars but we didn’t do that because in fact a ribbon button contains more properties than a toolbar button:

1) Two icons (big and small).

2) Advanced tooltip.

3) Behavior rules.

We could create a function which fills a ribbon page with buttons using toolbar and/or menu resources, but button properties would be initialized only partially. You would have to access particular buttons manually and provide them with required properties. This code would be very similar to ribbon initialization from scratch. You should be agree with us: a ribbon bar and toolbars/menus are quite different controls.

You can use your toolbars "as is". You can create a new command profile in the command manager (g_CmdManager->ProfileSetup( . . . )) and update it from all your existing toolbar and menu resources (g_CmdManager->UpdateFromMenu( . . . ), g_CmdManager->UpdateFromToolBar( . . . )). As a result, you get a fully initialized command profile in the command manager which contains a set of command descriptions and a set of ready to use command icons. The g_CmdManager->CmdGetPtr( . . . ) code returns a pointer to the CExtCmdItem object with all the text properties gathered from the menu resources and string tables. The g_CmdManager->CmdGetIconPtr( . . . ) code returns the CExtCmdIcon object which has a command image in the CExtCmdIcon::m_bmpNormal property. This image can be used for initializing a ribbon node. So, the command manager can split all your resources into individual command descriptions and command icons. These resources can be used for initializing the properties of ribbon nodes.

Robert Webb Sep 8, 2008 - 7:01 PM

Thanks, I have this working now, and am pulling the toolbar icons out of the command manager as you suggest.  It seems the command manager can only store one icon size for each command though, so I still needed to get the large icons from elsewhere.  I already had toolbar bitmaps at two different sizes.  I managed to use standard Windows calls to load the larger bitmaps and extract individual icons for ribbon bar buttons.


Rob.

Technical Support Sep 9, 2008 - 12:07 PM

Yes, only one icon per command is supported. But this is not a big problem. For instance, if you need a File/Open command displaying a small 16x16 icon in menu and a big 32x32 icon in toolbar, then you should use two command identifiers: first in the menu and second in the toolbar. These commands should be handled/updated by the same methods in some of your classes.

Technical Support Jul 15, 2008 - 1:34 PM

The CExtRibbonBar control is very extended version of the customizable toolbar control. I.e. ribbon bar is based on both CExtToolControlBar and CExtCustomizeSite classes. It’s possible to create ribbon elements inside customizable (and even non-customizable) toolbar, but most of ribbon buttons are performing event notifications via virtual methods of CExtRibbonBar and CExtRibbonPage classes. Besides toolbar control does not perform ribbon specific layout calculations of its buttons. We can assume your message as feature request. We suspect you need the CExtRibbonPage control demostrated in the RibbonPage sample application but it should behave like re-dockable toolbar.