Overview
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
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 )
{
CMainFrame * pMainframe = (CMainFrame *) AfxGetApp()->m_pMainWnd;
if ( bAddalogo )
{
pMainframe->m_wndStatusBar.AddIndicator(0,INDICATOR_LOGO);
int idx = pMainframe->m_wndStatusBar.CommandToIndex(INDICATOR_LOGO);
pMainframe->m_wndStatusBar.SetPaneWidth(idx,120);
pMainframe->m_wndStatusBar.SetPaneStyle(idx,
pMainframe->m_wndStatusBar.GetPaneStyle(idx)
| SBPS_NOBORDERS );
MPCLogoPane * pLogo = new MPCLogoPane;
pLogo->Create("Your App Name ",WS_CHILD|WS_VISIBLE,
&pMainframe->m_wndStatusBar,120);
pLogo->SetLogoFont("Arial", 18);
pMainframe->m_wndStatusBar.AddControl(pLogo,INDICATOR_LOGO);
}
else
{
pMainframe->m_wndStatusBar.RemovePane(INDICATOR_LOGO);
}
}
Classes
MPCStatusBar
MPCStatusBarPane
MPCStatusBarPaneControlInfo
Additionally, you can use the 'ready to use' MPCLogoPane
class to add a logo to your app, in the status bar.
MPCStatusBar
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
).
MPCStatusBarPane
This class allows you to get information about a pane in a MPCStatusBar
. See MPCStatusBar
.
MPCStatusBarPaneControlInfo
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.
MPCLogoPane
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.