Creating a Status Bar

A status bar, also known as a status window, is a horizontal window positioned at the bottom of a parent window. It displays status information defined by the application. The following screen shot shows a status bar.

You create a status bar by calling the CreateStatusWindow function. This class is registered when the common control DLL is loaded. You can use the InitCommonControls function to ensure that this DLL is loaded. To register the status bar class using the InitCommonControlsEx function, specify the ICC_BAR_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure you pass in the lpInitCtrls parameter.

Because status bars are windows, you can create a status bar by calling CreateWindow or CreateWindowEx and specifying the window class STATUSCLASSNAME.

The window procedure for the status bar control automatically sets the initial size and position of the window. The width is the same as that of the parent window's client area. The height is based on the width of the window's borders and on the metrics of the font currently selected into the status bar's device context.

The window procedure automatically adjusts the size of the status bar when it receives a WM_SIZE message. Typically, when the size of the parent window changes, the parent sends a WM_SIZE message to the status bar.

An application can set the minimum height of a status bar drawing area by sending the window an SB_SETMINHEIGHT message that specifies the minimum height in pixels. The drawing area does not include the window borders.

You retrieve the widths of the borders of a status bar by sending the window an SB_GETBORDERS message. The message includes the address of a three-element array that receives the widths.