CExtStatusControlBar: Managing a Status Bar's Panes is Getting Easier



Click here for a larger image.

Environment: VC++

Introduction

The article introduces an enhanced version of the standard MFC status bar control. The new class should enable you to easily add/remove panes to/from the application's status bar on the fly. The status bar's panes may contain almost any control you need: buttons, edits, animations, progress bars, and so forth.

The class is partially based on the status bar presented in the freeware version of the Prof-UIS library available at http://codeguru.com/docking/profuis.html.

How to Use It

The CExtStatusControlBar class is simple to use. To add it to your project, please follow the steps below:

  1. Put its source files (CExtStatusControlBar.cpp and CExtStatusControlBar.h) into the proper folder and add their file names to your Visual Studio project.

  2. Include its header to the appropriate header file. If you plan to use CExtStatusControlBar in several places of your application, it's reasonable to add it to your stdafx.h file.
  3. #include "CExtStatusControlBar.h"
  4. If you used CStatusBar, you should replace it with CExtStatusControlBar everywhere in the project.
  5. CExtStatusControlBar  m_wndStatusBar;

Sample

The StatusPanes sample project shows how to use the class in practice (including how to place controls into the control bar's panes).

List of Methods

  • BOOL AddPane(UINT nID, int nIndex)
  • Inserts a new pane into the status bar.

    Parameters
    nID
    ID of the pane to be added.
    nIndex
    The index of the newly created pane.
    Return Value
    Nonzero if successful.

  • BOOL RemovePane(UINT nID)
  • Deletes a pane from the status bar.

    Parameters
    nID
    ID of the pane to be deleted.
    Return Value
    Nonzero if successful.

  • BOOL AddPaneControl(CWnd* pWnd, UINT nID, BOOL bAutoDestroy)
  • Inserts a control into a specified pane.

    Parameters
    pWnd
    Pointer to the control to be added.
    nID
    ID of the target pane.
    bAutoDestroy
    Specifies whether the control should be destroyed when the pane is removed.
    Return Value
    Nonzero if successful; otherwise, zero.

  • BOOL AddPaneControl(HWND hWnd, UINT nID, BOOL bAutoDestroy)
  • Inserts a control into a specified pane.

    Parameters
    hWnd
    Handle to the control to be added.
    nID
    ID of the target pane.
    bAutoDestroy
    Specifies whether the control should be destroyed when the pane is removed.
    Return Value
    Nonzero if successful.


  • void DisableControl( int nIndex, BOOL bDisable=TRUE)
  • Disables the control at a specified pane.

    Parameters
    nIndex
    Index of the pane.
    bDisable
    Flag specifying that the control is enabled if it is set to TRUE.
     

  • int GetPanesCount() const

    Retrieves the current number of panes in the status bar.


  • void SetPaneWidth(int nIndex, int nWidth)

    Sets a width in pixels for a specified pane.

    Parameters
    nIndex
    Index of the pane.
    nStyle
    Width to be set.


  • void SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth)

    Sets the specified pane to a new ID, style, and width.

    Parameters
    nIndex
    Index of the pane whose style is to be set.
    nID
    New ID for the pane.
    nStyle
    New style for the pane.
    cxWidth
    New width for the pane.


  • void SetPaneStyle(int nIndex, UINT nStyle)

    Set the style of a status bar's pane. A pane's style determines how the pane appears.

    Parameters
    nIndex
    Index of the pane whose style is to be set.
    nStyle
    Style of the pane whose style is to be set.

Copyright

You can use this source absolutely free.

Reporting Bugs

Your questions, suggestions, and bug reports may be posted either to the forum below or to the forum at the Prof-UIS Web site.

Downloads

Download demo project - 14 Kb
Download source code - 41 Kb



Comments

  • GetPanePtr funtion can not work?

    Posted by solotek on 07/27/2004 10:20pm

    I used this class in my project, but when I call AddPane(), it will error. And I think it is caused by the GetPanePtr() for it can not return the correct address. Maybe I used this uncorrectly. Can you give me some advice?

    Reply
  • Tooltips missed ?

    Posted by Legacy on 01/23/2004 12:00am

    Originally posted by: Ramon Fabregat

    Hi,

    Nice & Impressive work, until I arrive and test.
    It is one of best StatusBar interface I�ve seen !!!
    Only a small commentary : Tooltips could be appreciated.

    Anyway, it is a good work. Thanks to share it.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: September 17, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

  • Best-in-Class organizations execute on a strategy that supports the multi-channel nature of customer requests. These leading organizations do not just open up their service infrastructures to accommodate new channels, but also empower their teams to deliver an effective and consistent experience regardless of the channel selected by the customer. This document will highlight the key business capabilities that support a Best-in-Class customer engagement strategy.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds