Click here to Skip to main content
13,093,097 members (68,779 online)
Click here to Skip to main content
Add your own
alternative version


52 bookmarked
Posted 16 Feb 2000

MPCStatusBar - An Enhanced CStatusBar

, 11 Jun 2003
Rate this:
Please Sign up or sign in to vote.
An enhanced CStatusBar to easily and dynamically add/remove controls on a status bar
  • Download demo project - 43 Kb
  • Download source files - 5 Kb

    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

    Additionaly, 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 statusbas at their rite 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 to 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
  • License

    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


    About the Author

    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionLicense? Pin
    Nathan Lewis29-Nov-07 5:48
    memberNathan Lewis29-Nov-07 5:48 
    GeneralClock in StatusBar Pin
    Anonymous16-May-05 7:53
    sussAnonymous16-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
    member1lokii28-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
    member1lokii28-Dec-04 19:03 
    GeneralNice Article,But one question though.... Pin
    Koundinya22-Apr-04 18:31
    memberKoundinya22-Apr-04 18:31 
    Questionhow can i change the backgroud clr? Pin
    Panda_w4-Nov-03 20:13
    memberPanda_w4-Nov-03 20:13 
    AnswerRe: how can i change the backgroud clr? Pin
    Anonymous23-Jan-04 5:35
    sussAnonymous23-Jan-04 5:35 
    GeneralDoesn't work properly on XP with CommonCtrl Lib 6 Pin
    Andreas Gut9-Oct-02 4:41
    memberAndreas Gut9-Oct-02 4:41 
    GeneralRe: Doesn't work properly on XP with CommonCtrl Lib 6 Pin
    Andreas Gut9-Oct-02 4:59
    memberAndreas Gut9-Oct-02 4:59 
    GeneralTrying to respond to the Edit box (enter key) Pin
    Anonymous21-May-02 12:58
    memberAnonymous21-May-02 12:58 
    GeneralRe: Trying to respond to the Edit box (enter key) Pin
    Gernot Frisch14-Jan-03 1:18
    memberGernot Frisch14-Jan-03 1:18 
    GeneralRe: Trying to respond to the Edit box (enter key) Pin
    Diarrhio1-Mar-03 7:52
    memberDiarrhio1-Mar-03 7:52 
    GeneralTo remove all the panes (NUM etc) Pin
    Anonymous21-May-02 12:21
    memberAnonymous21-May-02 12:21 
    GeneralRe: To remove all the panes (NUM etc) Pin
    Anonymous6-Oct-02 5:40
    sussAnonymous6-Oct-02 5:40 
    GeneralDisable "Ready" string. Pin
    Eric Lee28-Apr-02 16:54
    memberEric Lee28-Apr-02 16:54 
    GeneralRe: Disable "Ready" string. Pin
    Armen Hakobyan7-May-02 4:00
    memberArmen Hakobyan7-May-02 4:00 
    QuestionHow could i add the tips for pane and control? Pin
    Panda_w6-Apr-02 2:21
    memberPanda_w6-Apr-02 2:21 
    AnswerRe: How could i add the tips for pane and control? Pin
    Armen Hakobyan7-May-02 4:30
    memberArmen Hakobyan7-May-02 4:30 
    GeneralCool Pin
    nickong1-Mar-02 3:36
    membernickong1-Mar-02 3:36 
    GeneralProgress Control Pin
    Giancarlo25-Jun-01 5:54
    memberGiancarlo25-Jun-01 5:54 
    GeneralRe: Progress Control Pin
    raven_poet17-Aug-03 14:44
    memberraven_poet17-Aug-03 14:44 
    GeneralDisabled controls. Pin
    David Msika7-Jun-01 8:30
    memberDavid Msika7-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
    Peter Hartmann17-Feb-00 19:40
    sussPeter Hartmann17-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.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web04 | 2.8.170813.1 | Last Updated 12 Jun 2003
    Article Copyright 2000 by Pierre Mellinand
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid