Image of Navigational Map linked to Home / Contents / Search ActiveBar

by Brett Sheppard - GUI Computing
Image of Line Break

Editor's Note : Brett wanted to title this article "Sitting' on the Dockable Bay", but even for AVDF that was too bad a pun to condone!

ActiveBar is a control that will save you a tonne of development time and give your application the look and feel of Office and Visual Basic. It enables you to create dockable toolbars, sliding tabs, tabbed toolwindows and detachable menus. The ease with which you can do the above is definitely its strong point and it can all be done at design time or runtime.

ActiveBar contains a designer which makes using this control a breeze. It contains a Bands window where you can select what type of toolbar etc you want to create and a tools window where you design the types of buttons or menu options you want available.

I might start a little backwards here and first discuss how to go about making tools that can be included into the desired bands. Tools can be divided into categories that you define yourself. For example, you might have an Edit category where you have a paste, cut and copy tool. (There is a library of pre-defined tools and categories which is quite handy.) It's just a nifty way of keeping some order with the tools you create.

Once you create a new tool, the tools property page is the first thing you see. Here you can define what type of look you want the tool to have. Buttons and combo boxes are just some of the control types you can include. It also includes an icon generator where you can create cool little icons for your tool. This is great fun as you can manipulate the image to exactly what you want as it has a variety of image tools you can use. I really enjoyed the little "camera" included which enables you to run a small magnifying glass over any windows app and capture the graphics inside it. Tools can also be checked, enabled and have their appearance altered from here as well. There is also a way in which you can join a pop up menu to each tool, but I will discuss this a bit further on.

Once you have created the tools you want it is time to place them into the Bands window. The Bands window has three options. Tool Bar, Menu Bar and Popup. Choosing one of these three places it into a list within the window. Selecting it makes it available in the designer area where you can add different tools and design the layout you want it to have. For example, to make a dockable toolbar you would do the following.

  1. Select Toolbar from the Bands Window.
  2. Select that tool bar from the List. (This places it in the designer area.)
  3. Place the tools you have created into the tool bar area by dragging them from the Tools Window.
  4. Close the designer.
  5. Run your program.

It's that simple. You know how a dockable toolbar which can be moved all over your screen. You can also add pages to the tool bar band which so you can create a floating tabbed tool bar.

Of course, you can do a great deal more than that.

The pop menus, among other uses, provide you with a way of offering sub menus on your detachable menus. For example, you can add tools to a pop up menu in the same way as described with the toolbar. You can also select a menu bar which you can add another tool to. In this tools properties you can set a "sub band" which points to your pop up menu by way of a drop down combo which has all of the bands listed. When run, the menu will appear with its tool listed. Selecting that tool will cause the pop up menu to appear - just like selecting the File menu option in Visual Basic. A warning : don't have two pop up menus referring to each other as I did or it could get ugly <g>.

Creating toolbars at runtime is just as easy. The manual that comes with the control contains explanations on how all the objects relate to one another, which makes learning easier. The learning curve required here is minimal and should not be a problem. I have included a code example from the manual along with a partial screen shot of the running program to show how simple it can be.

Private Sub Form_Load()
   Dim tool As New tool
   
   ' Add the standard toolbar
   BarDemo.Bands.Add "Standard"
   
   ' Set wrapping to true (Default is False)
   BarDemo.Bands("Standard").Wrappable = True
   
   With BarDemo.Bands("Standard").Tools
   
      ' Add First Tool with id 101 and Name tiNew
       Set tool = .Add(101, "tiNew")
      
      ' Set the caption with an accelerator key
        tool.Caption = "&New"
      
      ' Load the normal picture (index 0) with a gray mask color
        tool.SetPicture Index:=0, Picture:=LoadPicture("c:\home.bmp"), color:=&HC0C0C0
      
      ' No separator line before this icon
       tool.BeginGroup = False
      
      ' Display style as a standard button.
       tool.Style = 0
      
      ' Repeat for the second tool
       Set tool = .Add(102, "tiOpen")
       tool.Caption = "&Open"
       tool.SetPicture Index:=0, Picture:=LoadPicture("c:\refresh.bmp"), color:=QBColor(8)
      
       tool.BeginGroup = False
      
       tool.Style = 0
   
    End With
   
   ' Force the toolbar to recalculate its layout and refresh
    BarDemo.RecalcLayout
     
End Sub

About 15 lines of code to produce a dockable toolbar. Do not remain calm!

This is a really great control that makes light work of what could be a programming nightmare. You can grab an evaluation of this product from http://www.datadynamics.com



Written by: Brett Sheppard
June '98

Image of Arrow linked to Previous Article Image of Arrow linked to Next Article
Image of Line Break
[HOME] [TABLE OF CONTENTS] [SEARCH]