A status bar is a horizontal window positioned, by default, at the bottom of a parent window. It displays status information that is defined by the application. This control can appear in one of two modes: as a simple-mode status bar (containing only one section) or as a multiple-part status bar (divided into various sections and able to display more than one type of status information). A multiple-part status bar can contain as many as 255 sections.
You can create a status bar in any of these three ways:
Use the CreateWindow or CreateWindowEx function, specifying
the STATUSCLASSNAME window class.
Use the MFC CStatusBar class and its member functions.
Use the MFC CStatusBarCtrl class and its member functions.
Notice that I've listed two MFC classes: CStatusBar and CStatusBarCtrl. MFC has supported the CStatusBar class in both 16-bit and 32-bit Windows. I will refer to this as the old-style control. MFC now uses the CStatusBarCtrl class to support the new Win32-only status bar control. These two classes are entirely different. If you want the same functionality that the Win32 control offers, you should use CStatusBarCtrl, even though you will need to create the status bar yourself. AppWizard provides a check box for status bars when you create your project, but using this check box produces an old-style status bar, not the Win32 control. (Also note that CStatusBarCtrl does not have built-in support for the old-style Caps Lock and Num Lock indicators.) I chose to write a sample in C and port it to MFC using the CStatusBarCtrl class.
With all this in mind, let's see what you can do with status bars. I wrote the STATUS sample in C to demonstrate what the text styles look like, how to write text in a status bar, how to use the status bar modes, and how to draw a bitmap in a status bar. Figure 1-1 shows the multiple-part status bar produced by the STATUS sample.
Figure 1-1.
In the lower right corner of the status bar, you will notice a sizing grip, which is similar to a sizing border. The user can drag this triangular area to resize the parent window. You can get this functionality by including the SBS_SIZEGRIP window style when you create your status bar. If you decide to include a sizing grip, you should avoid combining the CCS_TOP common control style and the SBS_SIZEGRIP style because this combination renders the sizing grip nonfunctional. The system will not even draw the sizing grip.