September 1997

Simple or complex status bars?

by Kent Reisdorph

A status bar can include just one panel or multiple panels. A single-panel status bar has one long panel that occupies the entire width of the panel--this appearance is the default and results from setting the SimplePanel property to True. When SimplePanel is True, you can display text in the status bar by modifying the SimpleText property:

StatusBar->SimpleText = "Ready";
When the SimplePanel property is set to False, C++Builder assumes that your status bar will have multiple panels. For example, an application used to edit text might display status information in the first panel, the cursor position in the next panel, and the editing mode (overtype or insert) in a third panel. The panels serve to visually distinguish the different types of information.

To create the individual panels at design time, you invoke the StatusBar Panels Editor. To see this editor, place a StatusBar component on your form, locate the Panels property in the Object Inspector, and then double-click in the value column. The StatusBar Panels Editor will appear, as shown in Figure A, letting you create the individual panels.

Figure A: You can create and format multiple status bar panels using the Panels Editor.

Figure A

We won't describe every panel option, because you can figure them out for yourself--experiment with the Panels Editor to see the effect of different option combinations on the appearance of your status bar.

If your status bar has multiple panels, then the syntax to set the text of the individual panels is a bit more complex than it is for a single-panel status bar. The following code snippet illustrates how to display text in both the first and the second panels of a multi-panel status bar:

StatusBar->Panels->Items[0]->Text = "Ready";
StatusBar->Panels->Items[1]->Text = "X: 0, Y: 0";
The first panel is panel 0, the second panel is panel 1, and so on. You can modify the properties for each panel (width, text alignment, bevel style, and so on) at runtime as well as at design time, although for most applications such modifications aren't necessary.

Kent Reisdorph is a editor of the C++Builder Developer's Journal as well as director of systems and services at TurboPower Software Company, and a member of TeamB, Borland's volunteer online support group. He's the author of Teach Yourself C++Builder in 21 Days and Teach Yourself C++Builder in 14 Days. You can contact Kent at editor@bridgespublishing.com.