The new vbAccelerator Site - more VB and .NET Code and Controls
Source Code
1 ActiveX Controls &nbsp

vbAccelerator ListBar Control

An accurate reproduction of the Microsoft Outlook Bar, incorporating a solid ComCtl32.DLL ListView implementation in VB for you to play with!

NOTE: this code has been superceded by the version at the new site.

vbAccelerator ListBar Demonstration Project - does this look good or what?

Download Code
VB5 code VB5 Control Binary (43kb) VB6 code VB6 Control Binary (44kb)
VB5 code VB5 Demonstration Project (38kb) VB6 code VB6 Demonstration Project (38kb)
VB5 code VB5 Full Source Code (156kb) VB6 code VB6 Full Source Code (153kb)
Required Files:
  • vbAccelerator SSubTmr.DLL for VB5
  • vbAccelerator VB5 ImageList control
  • Ole Guids and Interface Definitions type library (OleGuids.TLB)
  • Required Files:
  • vbAccelerator SSubTmr6.DLL for VB6
  • vbAccelerator VB6 ImageList control
  • Ole Guids and Interface Definitions type library (OleGuids.TLB)

  • &nbsp UpdatedUpdated! 21 March 2000 &nbsp
    &nbsp Added a VB6 version of the control and project, plus various bug fixes.

    Please Note: The new version of the VB5 control has a different filename and ProgID so it is not a drop-in replacement for the previous binary. This has been done because of a Bug in VB5 which prevented a new version from being compiled. As a consequence, if you want to take advantage of the bug fixes, you have to remove instances of the previous version of the control from your project and then reference the new version. Subsequent versions of this control will not suffer from the problem. Please accept my apologies.

    For existing projects only, you can still download the previous version.

    &nbsp Large Icon view did not always centre the icons correctly, particularly if they were added at run-time. &nbsp
    &nbsp Items could appear on top of each other in Small icon view if the bar was made larger. &nbsp
    &nbsp Cursors displayed the wrong way around - now correct so hand appears over sheets and pointer over items. &nbsp
    &nbsp Source Code Note &nbsp
    &nbsp This OCX is a binary compatible component which works with all other samples. If you compile your own copy of this OCX yourself please make sure you change the name. See disclaimer and license for more details. &nbsp

    The vbAccelerator ListBar control is an all-VB control which emulates the Outlook sidebar as accurately as possible. I was inspired to write it when I started playing with Microsoft's Spy++ utility and pointed it at Outlook's list bar (or "ShortcutBar" as it publicises itself to the world) and noticed that the main component of the ListBar was actually a standard COMCTL32.DLL ListView. Having just worked on Dan Litwin's excellent Custom-Draw TreeView Control I figured there would be no problem implementing a ListView like this and next thing there would be a super accurate Outlook Bar just ready for playing with. Not to mention I could provide you with in-place editing without writing any code, and provide Background Bitmap support so easily! How hard could it be?

    Well, one day I will be older and wiser and will stop saying "How hard can it be?" and may even stop having to compile my code at 4:30am and dragging in to work the next day with flies buzzing around my head. One day.

    In the meantime, here are the results! Go download the TreeView and the S-Grid Control and you will have a serious pair of complementary tools for building real world UI solutions. Combine everything with the ultimate in Windows style using the CoolMenu/ToolBar/Rebar control and you're well on your way to having a killer business app!

    Objective Gratification
    One of the differences between this control and many of the previous controls at vbAccelerator is that it has a fully-fledged object model - bars are programmed using the CListBar object which is collected in the CListBars collection, and within a bar items are modified using a CListBarItem object which is collected in the CListBarItems collection.

    The collection is shown in the object model:

    vbAccelerator Listbar Object Model
    vbAccelerator ListBar Object Model

    One of the issues with programming an object model like this is it is easy to get into problems with circular references; where objects are referred to by an external consumer of the control and by the control itself, which is also referred to by the consumer. Such problems can prevent the _Terminate event of objects ever firing. This situation is normally undesirable (causing memory leaks) but when you have subclassing and Win32 API controls it becomes uncontrollable, leading to UAE/GPFs whenever a form containing the control is closed.

    The object model coded in this control demonstrates one technique you can use to completely guarantee no possibility of a circular reference. The downside to the technique is that it requires more code to be run before an object is provided to the user. That isn't a problem in a control which is managing only a small number of objects, such as the Outlook bar (i.e. less than 1,000). But it would be unsuitable for use in a control like the vbAccelerator S-Grid control, which is currently capable of adding and displaying tens of thousands of objects at a reasonable speed.

    The Structure of the ListBar/Outlook Bar
    Structure Diagram
    As shown in the diagram above, the ListBar consists of 4 window parts.
    1. The Main Container
      This window is responsible for the border around the control and drawing the bar selection buttons. The border is either turned off or implemented using the extended window styles WS_EX_STATICEDGE for a thin 3D border or the WS_EX_CLIENTEDGE style for a standard 3D border. By using extended window styles to draw the control border, the internal dimensions of the control (.ScaleWidth and .ScaleHeight) are automatically adjusted to take account of the border and windows draws the border for you.

      In the Microsoft Outlook implementation, this window has a caption of "ShortcutBar" and a class name of "rctrl_renwnd32" - this class is used as a general container in Outlook.

    2. The Scroll ViewPort
      This window is responsible for clipping the areas of the ListBar which can't be seen as the ListBar is scrolled up and down. When the container resizes this window, it instructs it to detect whether the ListBar is bigger than its client area, so it can then determine whether to display the up and down buttons.

      In the Microsoft Outlook implementation, this window has the same class name as the main window and a caption of "FIScrollWnd".

    3. The ListBar
      This is the list of icons. In both the Microsoft and my implementation this is implemented using an API created ImageList control with the LVS_NOSCROLL style turned on. The same window is reused for each ListBar: when the bar selection button is clicked, a snapshot of the ListView display is taken and displayed, the ListView is then made invisible and filled with the new items and finally the container animates the ListView window in steps.

      Controlling the position of the icons in the ListView is performed by sending LVM_SETITEMPOSITION32 messages whenever the ListBar is resized.

      To implement the hot, mouse-over highlighting of buttons, the ListView Custom Draw services are used. Firstly, the ListView has the LVS_EX_ONECLICKACTIVATE extended style set, which causes the control to start highlighting hot items. The default highlighting scheme is to underline the text and colour it in the selected text colour, however when using the Custom Draw services you can override the colours and to some extent the graphics being drawn.

    4. The ScrollButtons
      This is the only area in which the vbAccelerator control diverges from the Outlook implementation. In Outlook, this control appears to be drawn directly onto the ListView, however the vbAccelerator control uses two standard VB CommandButton controls with the Style property set to Graphical. The face of the control is then drawn by overriding the WM_DRAWITEM message sent by the control.

    Code Used in the ListBar Control
    The ListBar control draws from source code in a number of other articles here at vbAccelerator:

    Documentation for the vbAccelerator ListBar control's properties, methods and classes is available as an RTF. This documentation was created with the ActiveX Documenter.

    Click here to download/view the vbAccelerator ListBar control method and event documentation

    TopBack to top
    Source Code - What We're About!Back to ActiveX Control Source Code
    Source Code - What We're About!Back to Source Code


    NOTE: this code has been superceded by the version at the new site.

    AboutContributeSend FeedbackPrivacy

    Copyright 1999-2000, Steve McMahon ( All Rights Reserved.
    Last updated: 21 March 2000