Saving and Loading Layouts

The ActiveBar Designer allows you to save and load toolbar layout files (.tb3). This functionality allows you to reuse toolbars and to store layouts to load at run time. You can store multiple layout files in your application for different locales based on user preferences. ActiveBar 3.0 can load layout files saved in ActiveBar 2.0 and 1.0; loading these layouts allows you to import old layout files and use them when upgrading to ActiveBar 3.0.

Note: When saving a layout with custom controls for future use, first disconnect these custom controls from ActiveBar. Otherwise, when ActiveBar releases references to the control, if nothing else holds a reference to it, ActiveBar deletes the control.

To save and load a layout at design time

  1. After designing your toolbar, click the Save icon in the ActiveBar Designer to display the Save dialog.
  2. Enter a name for the layout file and click Save.
  3. Click the Open icon in the ActiveBar Designer to display the Open File dialog.
  4. Select a saved layout (*.tb3) file and click Open.

To save and load a layout at run time

Add the following code to your project to save and load a layout at run time.

Note: To run the code sample below, add ActiveBar to a project, save two layouts named "Original Layout.tb3" and "Layout Changes.tb3" in your VB project folder, and add a button to the main form in your project named resetButton.

Option Explicit Private Sub ActiveBar31_ToolClick(ByVal Tool As ActiveBar3LibraryCtl.Tool) ' When the tool click occurs, the tool name prints in the immediates window. Debug.Print Tool.Name End Sub Private Sub resetButton_Click() ' Selecting the Reset button restores original layout. ActiveBar31.Tools.RemoveAll ActiveBar31.Bands.RemoveAll ActiveBar31.Load "", App.Path & "\Layout Changes.tb3", ddSOFile ActiveBar31.RecalcLayout End Sub Private Sub Form_Load() Dim standardBand As Band Dim buttonTool As Tool ' Loads the saved layout changes at start up. ActiveBar31.Tools.RemoveAll ActiveBar31.Bands.RemoveAll If Dir(App.Path & "\Original Layout.tb3") <> "" Then ActiveBar31.Load "", App.Path & "\Original Layout.tb3", ddSOFile Debug.Print "Layout Loaded" End If ActiveBar31.RecalcLayout End Sub Private Sub Form_Unload(Cancel As Integer) ' Saves the layout changes. ActiveBar31.SaveLayoutChanges App.Path & "\Layout Changes.tb3", ddSOFile End Sub

Layouts | Layout Documentation

 

 


Copyright © 2006 Data Dynamics, Ltd. All Rights Reserved.