Walkthrough: Adding Tools at Run Time

Adding tools at run time allows you to have full control over the code and design of the user interface of your application.

This walkthrough is split up into the following activities.

Adding the ActiveBar control and adding a toolbar at run time

To add the ActiveBar control and add a toolbar at run time
  1. Create a new Standard EXE project in Visual Basic 6.
  2. Add the ActiveBar Components to your project. (See Adding ActiveBar to a Project.)
  3. In the code view of the form, select Form in the Object list and Load in the Procedure list to create a Form_Load event.
  4. Add a toolbar to your application using code like the following.

    Private Sub Form_Load() ' instantiates band object Dim standardBand As ActiveBar3LibraryCtl.Band ' Adds band named "standardToolbar" to Activebar ' Bands Collection and displays Band on form Set standardBand = ActiveBar31.Bands.Add("standardToolbar") ' Sets band type standardBand.Type = ddBTNormal ' Switches on Stretch flag enabling ' Band to fill all space on Dockline standardBand.Flags = ddBFStretch End Sub

Adding tools at run time

To add tools at run time
  1. Add the following code to your project to instantiate the ActiveBar Tool object in the Form_Load event.

    Dim buttonTool As ActiveBar3LibraryCtl.Tool

  2. Add the following code to the Load event to add the ActiveBar Tool object to the Tools Collection.

    Set buttonTool = ActiveBar31.Bands("standardToolbar").Tools.Add(101, "newButton")

  3. Add the following code to the Load event to set the properties for the Tool.

    With buttonTool .Caption = "&New" .Category = "File" .ControlType = ddTTButton .Style = ddSText End With

  4. Use the ActiveBar_ToolClick event or other ActiveBar Library members to create functionality for your toolbar.
  5. Click Save and press F5 to run your application.

Adding ActiveBar to a Project | Creating a Toolbar

 

 


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