Compartilhar via


Initializing the Parts of a CStatusBarCtrl Object

By default, a status bar displays status information using separate panes. These panes (also referred to as parts) can contain either a text string, an icon, or both.

Use SetParts to define how many parts, and the length, the status bar will have. After you have created the parts of the status bar, make calls to SetText and SetIcon to set the text or icon for a specific part of the status bar. Once the part has been successfully set, the control is automatically redrawn.

The following example initializes an existing CStatusBarCtrl object (m_StatusBarCtrl) with four panes and then sets an icon (IDI_ICON1) and some text in the second part.

int strPartDim[4]= {80, 160, 240, -1};

m_StatusBarIcon = AfxGetApp()->LoadIcon(IDI_ICON1);

m_StatusBarCtrl.SetParts(4, strPartDim);
m_StatusBarCtrl.SetIcon(1, m_StatusBarIcon);
m_StatusBarCtrl.SetText(_T("Part 1"), 1, 0);

For more information on setting the mode of a CStatusBarCtrl object to simple, see Setting the Mode of a CStatusBarCtrl Object.

See Also

Reference

Using CStatusBarCtrl

Concepts

Controls (MFC)