Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering


You are here: Visual Basic > Advanced VB6 tutorial > Chapter 4

VB StatusBar - StatusBar Control in Visual Basic 6

The StatusBar control is another ActiveX Control available through the Windows Common Controls components. With the StatusBar, you can easily display information about the date, time, and other details about the application and the environment to the user.

Panel Object and Panels Collection

A StatusBar is made up of Panel objects, each of which displays different types of information. All the Panel objects are contained in the Panels Collection of the StatusBar. The appearance and purpose of each Panel is determined by the Style property of that Panel. The following styles are available:

  • sbrText (0) The Panel will display text information. The information displayed is in the Text property of the Panel.

  • sbrCaps (1) The Panel will contain the string "Caps". It will be highlighted if Caps Lock is turned on or disabled if Caps Lock is turned off.

  • sbrNum (2) The Panel will contain the string "Num". It will be highlighted if Num Lock is turned on or disabled if Num Lock is turned off.

  • sbrIns (3) The Panel will contain the string "Ins". It will be highlighted if Insert mode is turned on or disabled if Insert mode is turned off.

  • sbrScrl (4) The Panel will contain the string "Scrl". It will be highlighted if Scroll Lock is turned on or disabled if Scroll Lock is turned off.

  • sbrTime (5) The Panel will display the current time in the system format.

  • sbrDate (6) The Panel will display the current date in the system format.

  • sbrKana (7) The Panel will contain the string "Kana". It will be highlighted if Kana (a special character set only available in the Japanese PC market) is enabled or disabled if Kana is disabled.

Figure 4.12 shows an example of a status bar displaying all the different styles.

Different styles of the Panel object.
FIGURE 4.12 Different styles of the Panel object.

As with the other controls discussed in this chapter, the properties of the StatusBar and the Button objects can be set either through the Property Pages dialog box at design time or at runtime. The properties of the StatusBar control can be set on the General tab, as shown in Figure 4.13.

The Style and SimpleText properties of the toolbar determine the appearance of the control at runtime. The Style property can have one of two values: Simple or Normal. When the Style property is Simple, only one panel of the StatusBar is visible, and the text in the SimpleText property is displayed. When the Style property is Normal, the StatusBar appears with multiple panels.

General properties of the StatusBar.
FIGURE 4.13 General properties of the StatusBar.

Further properties of the Panel objects give more control over the appearance of a StatusBar control. These properties can be set on the Panels tab of the Property Pages dialog box, as shown in Figure 4.14, or at runtime.

Custom Properties of the Panel object.
FIGURE 4.14 Custom Properties of the Panel object.

The use of ToolTips is available to you with the StatusBar control. Behavior of ToolTips for the StatusBar is similar to the behavior of ToolTips for the ToolBar control (discussed earlier in "Using the ToolBar Control").

An individual ToolTipText property is available for each panel of the StatusBar control. When the ShowTips property of the StatusBar is set to True and the user rests the mouse pointer over a panel in the StatusBar, the ToolTipText is displayed at the mouse pointer.

Several other Panel properties affect the appearance of each panel. The Alignment property determines whether text displayed in a panel is left-justified, right-justified, or centered. The MinWidth property specifies the minimum width of a panel. The ScaleMode of the container on which the StatusBar is located determines the units for the MinWidth. Each panel also has a Width property that determines the starting width of the object.

The AutoSize property of a panel can also have an impact on its width. This property can have the following values:

  • sbrNoAutoSize (0) The panel size will not be changed automatically.

  • sbrSpring (1) If the size of the StatusBar increases as the size of the container grows, the width of the Panel will also increase. As a StatusBar grows smaller, the size of the Panel will not go below the MinWidth value.

  • sbrCntents (2) The Panel will be resized to fit its contents but will never fall below the MinWidth.

Another property that affects a panel's appearance is the Picture. Unlike the other controls discussed in this chapter, the StatusBar does not get images from an ImageList.

If you wish to include images—either bitmaps or icons—in a panel, you can add them through the Property Pages dialog box by specifying the file directly. You can also add them at runtime with the LoadPicture function, which takes the image file path as its argument, or by setting the Picture property to one of the ListImages in an ImageList control or to the appropriate bitmap property of some other control.

Related topics on StatusBar Control

See Also


  

<< Previous | Contents | Next >>

Home | Link to Us | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved