Status Bar Messages and Member Functions

Table 1-3 lists the messages that can be sent to status bars and the member functions supported by the MFC-supplied class CStatusBarCtrl. Because the table's purpose is to describe what you can do with a status bar, it does not include return values or parameter information. You can find details about parameters and return values in the Win32 SDK documentation and in the MFC 3.1 documentation.

Message Member Function Description
SB_GETBORDERS* GetBorders* Retrieves the current widths of the horizontal and vertical borders of a status bar. These measurements determine the spacing between the outer edge of the window and the rectangles in the window that contain text as well as the spacing between rectangles.
SB_GETPARTS GetParts Retrieves the number of parts in a status bar and, for each part, the coordinate of the right edge.
SB_GETRECT GetRect Retrieves the bounding rectangle of the given part of a status bar.

Table 1-3. (continued)

Status bar messages and member functions.

Message Member Function Description
SB_GETTEXT* GetText* Retrieves the text from the given part of a status bar. SB_GETTEXT returns a 32-bit value consisting of two 16-bit values. The low-order word specifies the length, in characters, of the text. The high-order word specifies the type of operation used to draw the text. If the text has a type of SBT_OWNERDRAW, the message returns the 32-bit value associated with the text instead of the length and type.
SB_GETTEXTLENGTH* GetTextLength* Retrieves the length, in characters, of the text from the given part of a status bar. SB_GETTEXTLENGTH returns a 32-bit value consisting of two 16-bit values. The low-order word specifies the length, in characters, of the text. The high-order word specifies the type of operation used to draw the text.
SB_SETBORDERS* SetBorders* Sets the widths of the horizontal and vertical borders of a status bar. These borders determine the spacing between the outer edge of the window and the rectangles within the window that contain text as well as the spacing between rectangles.
SB_SETMINHEIGHT* SetMinHeight* Sets the minimum height for a status bar. The sum of this minimum height (wParam) and the height of the vertical border of the window equals the minimum height of the entire window.
SB_SETPARTS SetParts Sets the number of parts in a status bar (no more than 255) and sets the coordinate of the right edge of each part. lParam is the address of an integer array that has the same number of elements as the number of parts specified by wParam. Each element in the array specifies the position, in client coordinates, of the right edge of the corresponding part. If an element is –1, the position of the right edge for that part extends to the right edge of the window.
SB_SETTEXT* SetText* Sets the text in the given part of a status bar. This message invalidates the portion of the window that has changed, causing the window to display the new text. wParam is the zero-based index of the part to set and the type of drawing operation. If this value is 255, the status bar is assumed to be in simple mode. lParam is the address of a null-terminated string that specifies the text to set. If wParam is SBT_OWNERDRAW, lParam represents 32 bits of data. The parent window must interpret and draw the data when it receives the WM_DRAWITEM message.
SB_SIMPLE SetSimple Specifies whether a status bar displays simple text or displays all window parts set by a previous SB_SETPARTS message.

* This message or member function can also be used with header controls (column headers), discussed in Chapter 3.