Export (0) Print
Expand All

CStatusBar Class

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

class CStatusBar : public CControlBar

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.

Header: afxext.h

Community Additions

ADD
Show:
© 2014 Microsoft