CStatusBar Class |
Description
The class responsible for creating and managing a status bar. Status bars display status information in a horizontal window at the bottom of an application window. Status bars are often divided into parts, and each part displays different status information.
Refer to the documentation that ships with the Microsoft Windows Software Development Kit for more information on the use of status bar controls.
CStatusBar Members:
CStatusBar | CStatusBar();Constructor for CStatusBar. |
BOOL CreateParts(int iParts, const int iPaneWidths[]) const;Creates one or more status bar parts.
HICON GetPartIcon(int iPart);Retrieves the icon for a part in the status bar.
CRect GetPartRect(int iPart);Retrieves the bounding rectangle of a part in the status bar.
int GetParts();Retrieves a count of the parts in the status bar.
CString GetPartText(int iPart) const;Retrieves the text from a part in the status bar.
BOOL SetPartIcon(int iPart, HICON hIcon);Sets the icon for a part in the status bar.
BOOL SetPartText(int iPart, LPCTSTR szText, UINT Style = 0) const;Sets the text for a part in the status bar.
BOOL SetPartWidth(int iPart, int iWidth) const;Sets the width of an existing status bar pane, or creates a new pane with the specified width.
void SetSimple(BOOL fSimple = TRUE);Specifies whether a status window displays simple text or displays all window parts set by a previous SB_SETPARTS message.
Base class Members
For base class members, refer to the members of CWnd.
Remarks
Like all common controls, the status control requires a parent window. This parent window is often a dialog, but simple windows can also be the parent window for a status control.
The following code segment demonstrates how to create four panes in a status bar, and add some text.
void CMainFrame::SetStatusText() { if (::IsWindow(GetStatusBar())) { // Get the coordinates of the frame window's client area. CRect rcClient = GetClientRect(); // width = max(300, rcClient.right) int width = (300 > rcClient.right) ? 300 : rcClient.right; int iPaneWidths[] = {width - 110, width - 80, width - 50, width - 20}; if (m_bShowIndicatorStatus) { // Create 4 panes GetStatusBar().CreateParts(4, iPaneWidths); // Or you could create the 4 panes this way // GetStatusBar().SetPartWidth(0, width - 110); // GetStatusBar().SetPartWidth(1, 30); // GetStatusBar().SetPartWidth(2, 30); // GetStatusBar().SetPartWidth(3, 30); SetStatusIndicators(); } // Place text in the 1st pane GetStatusBar().SetPartText(0, _T("Some Text")); } }
Summary Information
Header file | statusbar.h |
Win32/64 support | Yes |
WinCE support | Yes |
Library required | Comctl32.lib |