Most Recent Post | Index List
Monday, May 16, 2011When Office 2007 was just released, there was a lot of debate whether Microsoft should have really replaced the docking toolbars by the all new ribbon interface or rather left the user the choice between the classic familiar docking toolbars and the ribbon. While we think that in some cases, a ribbon interface works better and in other cases a docking toolbar is the preferred user interface, why not let the user choose? Users who know a toolbar menu system inside out might prefer to keep the user interface they are productive with while occasional users might find their way faster with a ribbon. Microsoft didn't allow users to make a choice for themselves and imposed the ribbon in most places throughout Office.
Technically, allowing the switch at runtime between a classic docking toolbar system and a ribbon UI isn't trivial. Due to its nature, the ribbon is deeply affecting its parent form. It needs to do quite sophisticated drawing to work well on glass frames, show an irregular application menu button on this glass frame as well as a QAT (Quick Access ToolBar). This means that when you want to allow the ribbon to dynamically disappear and a docking toolbar with regular form caption appear and vice versa, all the DWM API trickery that is done to make the ribbon look good on glass needs to be dynamically turned on and off.
We did quite a lot of research and work in this area and are happy to inform we're now offering a simple and easy to use API to dynamically switch between a docking toolbar and a ribbon with the latest version of TMS Advanced ToolBars & Menus v126.96.36.199. To make it easy to create your UI at design time, you can add two frames to your application. On one frame, layout the ribbon and on the other frame, layout the docking toolbars. Descend the main form from the TAdvToolBarForm class and add these two frames on the main form. At design time, this becomes:
Via two actions, one assigned to a button on the toolbar and one assigned to a button on the ribbon, the code is added that calls a TAdvToolBarForm to perform the switch between toolbar and ribbon:
Note that to make this work, a proper initialization of the TAdvToolBarForm needs to be performed to do the runtime switch between the ribbon and classic docking toolbar via the code:
procedure TForm5.Action1Execute(Sender: TObject); begin SwitchFromDockPanelToRibbon(toolbarframe.AdvDockPanel1, ribbonframe.AdvToolBarPager1); end; procedure TForm5.Action2Execute(Sender: TObject); begin SwitchFromRibbonToDockPanel(ribbonframe.AdvToolBarPager1, toolbarframe.AdvDockPanel1); end;
At runtime, press the ribbon button on the docking toolbar to switch to ribbon mode and press the toolbar button on the ribbon to switch to docking toolbar mode:
procedure TForm5.FormCreate(Sender: TObject); begin InitDockPanelAndRibbon(toolbarframe.AdvDockPanel1, ribbonframe.AdvToolBarPager1); end;
Full source code of the application that demonstrates this capability can be downloaded here. To use this technique, use TMS Advanced ToolBars and Menus v188.8.131.52 or later.
This blog post has received 4 comments.
Most Recent Post | Index List