CbrBand class

One band of a CoolBar: its caption, its picture, its control, its size, its place and the way the user can move and resize it. A program gets one from the CbrBands collection, and from that collection’s Add method.

Dim Band As CbrBand
Set Band = CoolBar1.Bands.Add(, "find", "Find")
Band.MinWidth = 600
Band.IdealWidth = 2400
Band.UseChevron = True
Debug.Print Band.Caption; " "; Band.UseChevron
' Output:
' Find True

A program cannot make a CbrBand object with New. A band that was removed from the collection no longer reaches the cool bar.

Size

The size of a band is its Width along the row and its Height, which is that of its row. MinWidth and MinHeight are the least room the band keeps for its control, and IdealWidth is the width at which the band shows all it has. Maximize gives the band its ideal width, and Minimize its smallest. A band narrower than its ideal width shows a chevron button where UseChevron is True.

A band of style CbrBandStyleFixedSize has a width that the cool bar works out from its contents, and the user cannot change it. An assignment to its Width raises run-time error 35800, Property is read-only if the style property is set to fixed size, and an assignment of True to its NewRow raises error 35801.

A negative Width, MinWidth, MinHeight or IdealWidth raises run-time error 380.

Moving the band

A band has two places. Its Index is its place in the collection, and its Position is its place in the cool bar. The user moves a band, and then its Position changes and its Index does not.

CoolBar1.Bands.Clear
CoolBar1.Bands.Add , "file", "File"
CoolBar1.Bands.Add , "edit", "Edit"
CoolBar1.Bands("edit").Position = 1
Debug.Print CoolBar1.Bands("file").Position; CoolBar1.Bands("file").Index
' Output:
'  2  1

An assignment to Position that leaves the band where it is, such as its own position, and one that is outside the cool bar, raises run-time error 380.

A control in the band

Child is the control the band holds, and the cool bar keeps it in the band’s area: see Holding a control. ChildEdge draws an edge at the top and the bottom of the area.

Properties

BackColor

The color behind the caption and the control of the band, while UseCoolBarColors is False. OLE_COLOR. Default: vbButtonFace. It shows only while the control is drawn without visual styles.

Caption

The text in the band. String. Default: empty. It stands beside the grip, after the band’s picture. HideCaption keeps it from being drawn.

Child

The control that the band holds. A control object, or Nothing for a band without one. Assigned with Set, it puts the control into the band; the control has to be on the cool bar. See Holding a control and the warning under A control in the band.

A control that is not on the cool bar, and the cool bar itself, raise run-time error 380.

ChildEdge

Whether the band draws an edge at the top and the bottom of its control. Boolean. Default: False.

An assignment of False takes the edge away again.

FixedBackground

Whether the background picture stays fixed to the cool bar instead of moving with the band. Boolean. Default: True. It has an effect while the band has a picture, its own or that of the cool bar.

ForeColor

The color of the caption, while UseCoolBarColors is False. OLE_COLOR. Default: vbButtonText.

Gripper

Whether the band shows its grip. A member of CbrBandGripperConstants. Default: CbrBandGripperNormal. A value that is not a member raises run-time error 380.

Height

The height of the band, which is that of its row, in the container’s scale units. Single, read-only.

An assignment raises run-time error 383.

HideCaption

Whether the caption is kept from being drawn. Boolean. Default: False.

ID

The number by which the cool bar’s window knows the band, in the messages that Windows sends about it. Long, read-only. It stays with the band when the band moves.

IdealWidth

The width at which the band shows all it has, in the container’s scale units. Single. Default: 0, which is no ideal width. See Size.

Image

The picture of the band: its number in the cool bar’s ImageList, or its key. Variant. Default: 0, which is no picture. It is what the program gave to the property or to Add: a key stays a key.

A key that the image list does not have, or a key when the cool bar has no image list, raises run-time error 35601, Element not found. A negative number raises error 35600, Index out of bounds, and the band keeps its picture after either error.

ImageIndex

The number of the band’s picture in the image list. Long, read-only. It is 0 for a band without a picture, and it is the number that a key stands for.

Index

The number of the band in the CbrBands collection, from 1. Long, read-only. It changes when a band is added or removed before this one, and not when the band is moved in the cool bar.

Key

The key of the band in the collection. String. Empty for a band without a key.

An assignment gives the band another key, and the collection no longer finds it by the old one. An empty string takes the key away. A key that another band has raises run-time error 457, and the band keeps its key.

MinHeight

The least height of the band’s area, in the container’s scale units. Single. Default: 24 device-independent pixels. See Size.

MinWidth

The least width of the band’s area, in the container’s scale units. Single. Default: 0. See Size.

NewRow

Whether the band starts a row of the cool bar. Boolean. Default: False.

The first band of the cool bar, at position 1, cannot start a row: True for it raises run-time error 35801, Property is read-only if the style property is set to fixed size or the position property is 1.

Picture

A bitmap that fills the background of this band, while UseCoolBarPicture is False. A picture object. Default: Nothing.

Position

The band’s place in the cool bar, counted from 1 along the rows. Long. Assigned a number, it moves the band there. See Moving the band.

Style

Whether the user can resize the band. A member of CbrBandStyleConstants. Default: CbrBandStyleNormal. A value that is not a member raises run-time error 380.

Tag

A value of the program’s own, which the cool bar does not use. Variant: it holds a value of any type, an object included, which is assigned with Set. A new band has an empty string.

ToolTipText

The text shown in a small window when the pointer rests on the band’s caption, while the cool bar’s ShowTips is True. String. Default: empty.

UseChevron

Whether the band shows a chevron button where the cool bar gives it less room than its IdealWidth. Boolean. Default: False. See The chevron.

UseCoolBarColors

Whether the band takes the colors of the cool bar, its BackColor and ForeColor, instead of its own. Boolean. Default: True.

UseCoolBarPicture

Whether the band takes the Picture of the cool bar, instead of its own. Boolean. Default: True.

Visible

Whether the band is shown. Boolean. Default: True.

Width

The width of the band along its row, in the container’s scale units. Single. See Size for the case of a fixed size and for the values that are refused.

Methods

Maximize

Makes the band as wide as its IdealWidth, or, for a band without one, as wide as the row allows. The other bands of the row make room.

Syntax: object.Maximize

Minimize

Makes the band as narrow as its MinWidth allows.

Syntax: object.Minimize

PushChevron

Presses the band’s chevron button as the user does, which raises BandChevronPushed. It has an effect while UseChevron is True and the chevron is shown.

Syntax: object.PushChevron

See Also