CommandBars Articles and Tutorials

Stretch a Toolbar to Fill the Entire Width of the Application

Author: Mike Palmatier
Platform: Visual Basic 6.0

The CommandBars.EnableDocking method is used to apply the xtpFlagStretched flag from the XTPToolBarFlags enumeration. This will keep stretching the toolbar the entire width (if horizontal) of the application, even when there are not enough buttons to fill the toolbar. With the xtpFlagStretched flag, no other toolbars can be docked on the same row. Note that this is the default setting given to the ActiveMenuBar.

The picture below illustrates a toolbar with hidden buttons.

Toolbar with hidden buttons

If you would like to stretch a toolbar and also allow other toolbars to be docked on the same row you can use the xtpFlagStretchedShared flag.

The code below illustrates how to stretch a toolbar the entire width of the application.

Dim ToolBar As CommandBar

Set ToolBar = CommandBars.Add("Standard", xtpBarTop)
ToolBar.EnableDocking xtpFlagStretched