CMFCStatusBar Class
The CMFCStatusBar class implements a status bar similar to the CStatusBar class. However, the CMFCStatusBar class has features not offered by the CStatusBar class, such as the ability to display images, animations, and progress bars; and the ability to respond to mouse double-clicks.
class CMFCStatusBar : public CPane
Members
Public Methods
Name |
Description |
---|---|
(Overrides CBasePane::CalcFixedLayout.) |
|
|
|
Creates a control bar and attaches it to the CPane object. (Overrides CPane::Create.) |
|
Creates a control bar and attaches it to the CPane object. (Overrides CPane::CreateEx.) |
|
Determines whether another pane can be dynamically inserted between this pane and the parent frame. (Overrides CBasePane::DoesAllowDynInsertBefore.) |
|
Enables or disables the handling of mouse double-clicks on the status bar. |
|
Displays a progress bar on the specified pane. |
|
Returns the number of panes on the status bar. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns the pane style. (Overrides CBasePane::GetPaneStyle.) |
|
|
|
Returns the width, in pixels, of the specified pane of the status bar. |
|
Returns the tool tip text for the specified pane of the status bar. |
|
Invalidates the specified pane and redraws its content. |
|
Called by the framework before the creation of the Windows window attached to this CWnd object. (Overrides CWnd::PreCreateWindow.) |
|
|
|
|
|
Assigns an animation to the specified pane. |
|
Sets the background color for the specified pane of the status bar. |
|
Sets the indicator icon for the specified pane of the status bar. |
|
|
|
Sets the current progress of the progress bar for the specified pane of the status bar. |
|
Sets the style of the pane. (Overrides CBasePane::SetPaneStyle.) |
|
|
|
Sets the text color for the specified pane of the status bar. |
|
Sets the width in pixels of the specified pane of the status bar. |
|
Sets the tool tip text for the specified pane of the status bar. |
Protected Methods
Name |
Description |
---|---|
Called by the framework when it redraws the pane of the status bar. |
Remarks
The following diagram shows a figure of the status bar from Status Bar Demo sample application.
Example
The following example demonstrates the local variables that the application uses to call various methods in the CMFCStatusBar class. These variables are declared in StatusBarDemoView.h. The main frame is declared in MainFrm.h, the document is declared in StatusBarDemoDoc.h, and the view is declared in StatusBarDemoView.h. This code snippet is part of the Status Bar Demo sample.
int m_nProgressCurr;
BOOL m_bInProgress;
CImageList m_imlStatusAnimation;
BOOL m_bInAnimation;
CBitmap m_bmpIcon1;
CBitmap m_bmpIcon2;
The following example demonstrates how to get a reference to CMFCStatusBar object by introducing the GetStatusBar method in MainFrm.h and then calling this method from the GetStatusBar method in StatusBarDemoView.h. This code snippet is part of the Status Bar Demo sample.
// in MainFrm.h
public:
CMFCStatusBar& GetStatusBar ()
{
return m_wndStatusBar;
}
...
// in StatusBarDemoView.h
CMFCStatusBar& GetStatusBar () const
{
return ((CMainFrame*) AfxGetMainWnd ())->GetStatusBar ();
}
The following example demonstrates how to call various methods in the CMFCStatusBar class in StatusBarDemoView.cpp. The constants are declared in MainFrm.h. The example shows how to set the icon, set the tooltip text of the status bar pane, display a progress bar on the specified pane, assign an animation to the specified pane, set the text and the width of the status bar pane, and set the current progress indicator of the progress bar for the status bar pane. This code snippet is part of the Status Bar Demo sample.
// in MainFrm.h
const int nStatusIcon = 0;
const int nStatusInfo = 1;
const int nStatusProgress = 2;
const int nStatusLabel = 3;
const int nStatusAnimation = 4;
...
// in StatusBarDemoView.cpp
GetStatusBar ().SetPaneIcon (nStatusIcon, m_bmpIcon1);
GetStatusBar ().SetTipText (nStatusIcon, _T("This is a tooltip"));
...
GetStatusBar ().EnablePaneProgressBar (nStatusProgress, PROGRESS_MAX);
...
GetStatusBar ().SetPaneAnimation (nStatusAnimation, NULL);
...
GetStatusBar ().SetPaneAnimation (nStatusAnimation, m_imlStatusAnimation);
GetStatusBar ().SetPaneText (nStatusAnimation, _T(""));
GetStatusBar ().SetPaneWidth (nStatusAnimation, 16);
...
GetStatusBar ().SetPaneProgress (nStatusProgress, m_nProgressCurr);
Inheritance Hierarchy
Requirements
Header: afxstatusbar.h