Click here to Skip to main content
15,609,135 members
Articles / Desktop Programming / MFC
Posted 16 Feb 2000


52 bookmarked

MPCStatusBar - An Enhanced CStatusBar

Rate me:
Please Sign up or sign in to vote.
4.44/5 (3 votes)
11 Jun 2003
An enhanced CStatusBar to easily and dynamically add/remove controls on a status bar

Sample Image - MPCStatusBar.gif


The MPCStatusBar class allows you to easily add/remove standard indicators, and/or add/remove controls on the status bar. MPCStatusBarPane and MPCStatusBarPaneControlInfo classes comes with MPCStatusBar.

Additionally, there's a "ready to use" class, the MPCLogoPane class, that you can use to add the logo of your firm, or software on the left side of the status bar. Of course, a simple MDI application comes with the source code, where you can see the MPCStatusBar class used in conjunction MPCLogoPane and a standard CEdit on the status bar.


Sample source code to dynamically add/remove a control:

Declare a MPCStatusBar in replacement of CStatusBar, in your mainframe.h (or childframes):

MPCStatusBar m_wndStatusBar;

A sample function to add/remove a control:

void Function_addcontrol( BOOL bAddalogo )
    // Get the mainframe
    CMainFrame * pMainframe = (CMainFrame *) AfxGetApp()->m_pMainWnd;

    if ( bAddalogo )
        // Add an indicator, with width, ..
        // set the width and style
        int idx = pMainframe->m_wndStatusBar.CommandToIndex(INDICATOR_LOGO);
                                  | SBPS_NOBORDERS );

        // Create a log pane window, and append it to status bar
        MPCLogoPane * pLogo = new MPCLogoPane;
        pLogo->Create("Your App Name ",WS_CHILD|WS_VISIBLE,
        pLogo->SetLogoFont("Arial", 18);


  • MPCStatusBar
  • MPCStatusBarPane
  • MPCStatusBarPaneControlInfo

Additionally, you can use the 'ready to use' MPCLogoPane class to add a logo to your app, in the status bar.


This is the class you use in replacement of CStatusBar.

  • void PositionControls()

    Used to move the controls in the statusbar at their right place (==the RECT of the indicator). Internally used.

  • MPCStatusBarPaneControlInfo * GetPanControl(int nPaneID)

    Return some information about a control on an indicator, or NULL.

  • BOOL AddControl(CWnd * pWnd, int nPaneID, BOOL bAutodeleteControl = TRUE )

    Insert a control (pWnd) on a pane (nPaneID). If bAutodelete is TRUE, the control's window will be closed, and the control deleted, when the pane (nPaneID) will be removed, or MPCStatusBar destructor called. Returns TRUE if control appended. Before you append a control on a pane, you need to create a pane (see AddIndicator), or use an already existing pane that is not already used for a control.

  • void SetPaneWidth(int index, int cxWidth)

    Change the width of a pane (with or without a control)

  • BOOL AddIndicator( int position, UINT paneID)

    Add an indicator to the statusbar.

  • BOOL GetStatusPane(int nIndex, MPCStatusBarPane & xfxpane)

    xfxpane is filled with some information about the pane at nIndex.

  • void RemovePane(int nPaneID)

    Remove a pane. If the pane has a control, it is deleted if the control was added with autodelete=true (see AddControl).


This class allows you to get information about a pane in a MPCStatusBar. See MPCStatusBar.

  • UINT nID;

    The ID of pane

  • int cxText;

    Text size

  • UINT nStyle;

    Style of indicator

  • UINT nFlags;

    Internal flags used by MFC

  • CString strText;

    Text of pane

  • MPCStatusBarPane::MPCStatusBarPane(MPCStatusBarPane & xfxpane )

    Copy constructor

  • MPCStatusBarPane& MPCStatusBarPane::operator=(MPCStatusBarPane & xfxpane )

    Assignment operator


This class allows you to get additional information about a pane in a MPCStatusBar, having a control.

  • CWnd * m_hWnd;

    The control

  • int m_nPaneID;

    The pane where this control is on

  • BOOL m_bAutodelete;

    Indicator of autodeletion when the pane is removed, of when MPCStatusBar's destructor is called.


  • BOOL MPCLogoPane::Create(CString sText, DWORD dwStyle, CWnd * pParent, UINT nID)
    • sText -- text you want to display in the window
    • dwStyle -- style of window (WS_CHILD | WS_VISIBLE to use in the status bar)
    • nID -- ID of window
  • void MPCLogoPane::SetLogoFont(CString Name, int nHeight/* = 24*/, int nWeight/* = FW_BOLD*/, BYTE bItalic/* = true*/, BYTE bUnderline/* = false*/)

    Set the font for the displaying text.

  • void MPCLogoPane::SetLogoText(CString sTxt)

    Set the text to display


This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.

Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionLicense? Pin
Nathan Lewis29-Nov-07 5:48
Nathan Lewis29-Nov-07 5:48 
GeneralClock in StatusBar Pin
Anonymous16-May-05 7:53
Anonymous16-May-05 7:53 
Generalhello is it possible to check the ready state of the normal window (Except internet explorer)and other applications Pin
1lokii28-Dec-04 19:06
1lokii28-Dec-04 19:06 
Generalhello is it possible to check the ready state of the normal window and other applications Pin
1lokii28-Dec-04 19:03
1lokii28-Dec-04 19:03 
GeneralNice Article,But one question though.... Pin
Koundinya22-Apr-04 18:31
Koundinya22-Apr-04 18:31 
Questionhow can i change the backgroud clr? Pin
Panda_w4-Nov-03 20:13
Panda_w4-Nov-03 20:13 
AnswerRe: how can i change the backgroud clr? Pin
Anonymous23-Jan-04 5:35
Anonymous23-Jan-04 5:35 
GeneralDoesn't work properly on XP with CommonCtrl Lib 6 Pin
Andreas Gut9-Oct-02 4:41
Andreas Gut9-Oct-02 4:41 
GeneralRe: Doesn't work properly on XP with CommonCtrl Lib 6 Pin
Andreas Gut9-Oct-02 4:59
Andreas Gut9-Oct-02 4:59 
GeneralTrying to respond to the Edit box (enter key) Pin
21-May-02 12:58
suss21-May-02 12:58 
GeneralRe: Trying to respond to the Edit box (enter key) Pin
Gernot Frisch14-Jan-03 1:18
Gernot Frisch14-Jan-03 1:18 
GeneralRe: Trying to respond to the Edit box (enter key) Pin
Diarrhio1-Mar-03 7:52
Diarrhio1-Mar-03 7:52 
GeneralTo remove all the panes (NUM etc) Pin
21-May-02 12:21
suss21-May-02 12:21 
GeneralRe: To remove all the panes (NUM etc) Pin
Anonymous6-Oct-02 5:40
Anonymous6-Oct-02 5:40 
GeneralDisable "Ready" string. Pin
28-Apr-02 16:54
suss28-Apr-02 16:54 
GeneralRe: Disable "Ready" string. Pin
Armen Hakobyan7-May-02 4:00
professionalArmen Hakobyan7-May-02 4:00 
QuestionHow could i add the tips for pane and control? Pin
Panda_w6-Apr-02 2:21
Panda_w6-Apr-02 2:21 
AnswerRe: How could i add the tips for pane and control? Pin
Armen Hakobyan7-May-02 4:30
professionalArmen Hakobyan7-May-02 4:30 
GeneralCool Pin
Ray Guan1-Mar-02 3:36
Ray Guan1-Mar-02 3:36 
GeneralProgress Control Pin
25-Jun-01 5:54
suss25-Jun-01 5:54 
GeneralRe: Progress Control Pin
raven_poet17-Aug-03 14:44
raven_poet17-Aug-03 14:44 
GeneralDisabled controls. Pin
7-Jun-01 8:30
suss7-Jun-01 8:30 
GeneralCool code. Small questions. Please help. Pin
Erich J. Ruth8-Jun-00 14:04
sussErich J. Ruth8-Jun-00 14:04 
GeneralThe app name Pin
Member 337017-Feb-00 19:40
Member 337017-Feb-00 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.