Click here to Skip to main content
13,897,352 members
Click here to Skip to main content
Add your own
alternative version


28 bookmarked
Posted 23 May 2002

Display colored text on Status Bar

, 23 May 2002
Rate this:
Please Sign up or sign in to vote.
An article with code on displaying colored text on panes in a Status Bar using MFC


I wondered how to change text color of panes on the status bar same as what Visual SourceSafe file difference window does. In this article, I will show how to make status bar panes display their text in different colors. A regular status bar  can have many panes. It could be desirable in some cases that each pane's text could be displayed in a different color.

If you open the demo project file in Visual C++, you will see two new files, namely ColoredStatusBarCtrl.cpp and ColoredStatusBarCtrl.h. CColoredStatusBarCtrl wraps the owner-drawn capability of CStatusBar MFC class.

Besides above stuff, you could see some changes in MainFrm.cpp and MainFrm.h.

  1. In MainFrm.h, the following line is inserted before the class definition
  2. #include "ColoredStatusBarCtrl.h"
  3. Now look for following line
  4. CStatusBar m_wndStatusBar;

    Its class type is changed to 

    CColoredStatusBarCtrl m_wndStatusBar;
  5. In MainFrm.cpp, look for following array declaration 
  6. static UINT indicators[] =

    I created empty entries in string table for above ids. They will just stay there doing nothing.

  7. Now in CMainFrame::OnCreate(), I inserted the following code before the return statement:
  8. for (int i=0; i<4; i++)
        // Change Status Bar style to make it Owner-drawn
        m_wndStatusBar.GetStatusBarCtrl().SetText("", i, SBT_OWNERDRAW); 
        // Make each pane's of same size
        m_wndStatusBar.SetPaneInfo( i, 
            m_wndStatusBar.GetItemID(i), SBPS_STRETCH, NULL );


CColoredStatusBarCtrl is not generic. You may need to tweak it to make it workable for you. It just makes the point. I wish I could write a control for it.


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

The Code Machine
Software Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 3 Pin
wolfgangpuelm29-Sep-10 5:46
professionalwolfgangpuelm29-Sep-10 5:46 
GeneralRe: My vote of 3 Pin
The Code Machine13-Oct-10 19:39
memberThe Code Machine13-Oct-10 19:39 
QuestionDear Pin
teth3-Feb-08 22:13
memberteth3-Feb-08 22:13 
GeneralChange Color based on Error Pin
NYTSX3-May-06 4:32
memberNYTSX3-May-06 4:32 
GeneralRe: Change Color based on Error Pin
The Code Machine24-Aug-06 6:18
memberThe Code Machine24-Aug-06 6:18 
GeneralBrilliat !! Pin
Alton Williams21-Jun-05 2:53
memberAlton Williams21-Jun-05 2:53 
GeneralResource problem Pin
shrinivasbk7-Jul-04 1:37
membershrinivasbk7-Jul-04 1:37 
QuestionHow to add to Dialog Box Pin
mistroseth7-Apr-03 9:57
membermistroseth7-Apr-03 9:57 
GeneralI have completed it, and it works well with SetPaneText member function Pin
cadinfo10-Nov-02 2:32
membercadinfo10-Nov-02 2:32 
GeneralRe: I have completed it, and it works well with SetPaneText member function Pin
vikas amin25-Aug-05 23:41
membervikas amin25-Aug-05 23:41 
QuestionWhat about SetPaneText() Pin
spentaro15-Jul-02 19:41
memberspentaro15-Jul-02 19:41 
AnswerRe: What about SetPaneText() Pin
The Code Machine15-Jul-02 20:53
memberThe Code Machine15-Jul-02 20:53 
GeneralRe: What about SetPaneText() Pin
spentaro16-Jul-02 8:30
memberspentaro16-Jul-02 8:30 
GeneralRe: What about SetPaneText() Pin
The Code Machine16-Jul-02 20:53
memberThe Code Machine16-Jul-02 20:53 
GeneralI do something like this,very good to use! Pin
lilyflower5-Aug-02 22:36
memberlilyflower5-Aug-02 22:36 
Generala little change,but no twinkle(status bar) Pin
mclxly5-Dec-06 16:42
membermclxly5-Dec-06 16:42 
QuestionRe: I do something like this,very good to use! Pin
xu_qing14-Mar-07 6:15
memberxu_qing14-Mar-07 6:15 
AnswerRe: I do something like this,very good to use! Pin
The Code Machine21-Mar-07 15:10
memberThe Code Machine21-Mar-07 15:10 
GeneralRe: I do something like this,very good to use! Pin
rbrunton8-Feb-15 1:47
memberrbrunton8-Feb-15 1:47 
GeneralRe: What about SetPaneText() Pin
bkshrinivas7-Jun-04 1:45
memberbkshrinivas7-Jun-04 1:45 
AnswerRe: What about SetPaneText() Pin
Dbltrimmer30-Oct-05 7:36
memberDbltrimmer30-Oct-05 7:36 
GeneralVery very important, Onkar Singh tread this!!!! Pin
4-Jun-02 12:06
suss4-Jun-02 12:06 

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 | Cookies | Terms of Use | Mobile
Web05 | 2.8.190306.1 | Last Updated 24 May 2002
Article Copyright 2002 by The Code Machine
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid