Share via


CStatusBar Class

A control bar with a row of text output panes, or "indicators."

class CStatusBar : public CControlBar

Members

Public Constructors

Name

Description

CStatusBar::CStatusBar

Constructs a CStatusBar object.

Public Methods

Name

Description

CStatusBar::CommandToIndex

Gets index for a given indicator ID.

CStatusBar::Create

Creates the status bar, attaches it to the CStatusBar object, and sets the initial font and bar height.

CStatusBar::CreateEx

Creates a CStatusBar object with additional styles for the embedded CStatusBarCtrl object.

CStatusBar::DrawItem

Called when a visual aspect of an owner-draw status bar control changes.

CStatusBar::GetItemID

Gets indicator ID for a given index.

CStatusBar::GetItemRect

Gets display rectangle for a given index.

CStatusBar::GetPaneInfo

Gets indicator ID, style, and width for a given index.

CStatusBar::GetPaneStyle

Gets indicator style for a given index.

CStatusBar::GetPaneText

Gets indicator text for a given index.

CStatusBar::GetStatusBarCtrl

Allows direct access to the underlying common control.

CStatusBar::SetIndicators

Sets indicator IDs.

CStatusBar::SetPaneInfo

Sets indicator ID, style, and width for a given index.

CStatusBar::SetPaneStyle

Sets indicator style for a given index.

CStatusBar::SetPaneText

Sets indicator text for a given index.

Remarks

The output panes commonly are used as message lines and as status indicators. Examples include the menu help-message lines that briefly explain the selected menu command and the indicators that show the status of the SCROLL LOCK, NUM LOCK, and other keys.

CStatusBar::GetStatusBarCtrl, a member function new to MFC 4.0, allows you to take advantage of the Windows common control's support for status bar customization and additional functionality. CStatusBar member functions give you most of the functionality of the Windows common controls; however, when you call GetStatusBarCtrl, you can give your status bars even more of the characteristics of a Windows 95/98 status bar. When you call GetStatusBarCtrl, it will return a reference to a CStatusBarCtrl object. See CStatusBarCtrl for more information about designing toolbars using Windows common controls. For more general information about common controls, see Common Controls in the Windows SDK.

The framework stores indicator information in an array with the leftmost indicator at position 0. When you create a status bar, you use an array of string IDs that the framework associates with the corresponding indicators. You can then use either a string ID or an index to access an indicator.

By default, the first indicator is "elastic": it takes up the status-bar length not used by the other indicator panes, so that the other panes are right-aligned.

To create a status bar, follow these steps:

  1. Construct the CStatusBar object.

  2. Call the Create (or CreateEx) function to create the status-bar window and attach it to the CStatusBar object.

  3. Call SetIndicators to associate a string ID with each indicator.

There are three ways to update the text in a status-bar pane:

  1. Call CWnd::SetWindowText to update the text in pane 0 only.

  2. Call CCmdUI::SetText in the status bar's ON_UPDATE_COMMAND_UI handler.

  3. Call SetPaneText to update the text for any pane.

Call SetPaneStyle to update the style of a status-bar pane.

For more information on using CStatusBar, see the article Status Bar Implementation in MFC and Technical Note 31 : Control Bars.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CControlBar

CStatusBar

Requirements

Header: afxext.h

See Also

Reference

CControlBar Class

Hierarchy Chart

CStatusBarCtrl Class

CControlBar Class

CWnd::SetWindowText

CStatusBar::SetIndicators

Concepts

MFC Sample CTRLBARS

MFC Sample DLGCBR32