Click here to Skip to main content
11,927,324 members (58,012 online)
Click here to Skip to main content
Add your own
alternative version


27 bookmarked

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

Sample Image - colorstatusbar.jpg


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 6:46
memberwolfgangpuelm29-Sep-10 6:46 
GeneralRe: My vote of 3 Pin
The Code Machine13-Oct-10 20:39
memberThe Code Machine13-Oct-10 20:39 
QuestionDear Pin
teth3-Feb-08 23:13
memberteth3-Feb-08 23:13 
GeneralChange Color based on Error Pin
NYTSX3-May-06 5:32
memberNYTSX3-May-06 5:32 
GeneralRe: Change Color based on Error Pin
The Code Machine24-Aug-06 7:18
memberThe Code Machine24-Aug-06 7:18 
GeneralBrilliat !! Pin
Alton Williams21-Jun-05 3:53
memberAlton Williams21-Jun-05 3:53 
GeneralResource problem Pin
shrinivasbk7-Jul-04 2:37
membershrinivasbk7-Jul-04 2:37 
QuestionHow to add to Dialog Box Pin
mistroseth7-Apr-03 10:57
membermistroseth7-Apr-03 10:57 
GeneralI have completed it, and it works well with SetPaneText member function Pin
cadinfo10-Nov-02 3:32
membercadinfo10-Nov-02 3:32 
GeneralRe: I have completed it, and it works well with SetPaneText member function Pin
vikas amin26-Aug-05 0:41
membervikas amin26-Aug-05 0:41 
QuestionWhat about SetPaneText() Pin
spentaro15-Jul-02 20:41
memberspentaro15-Jul-02 20:41 
AnswerRe: What about SetPaneText() Pin
Onkar Singh15-Jul-02 21:53
memberOnkar Singh15-Jul-02 21:53 
GeneralRe: What about SetPaneText() Pin
J. Spencer Greene16-Jul-02 9:30
sussJ. Spencer Greene16-Jul-02 9:30 
GeneralRe: What about SetPaneText() Pin
Onkar Singh16-Jul-02 21:53
memberOnkar Singh16-Jul-02 21:53 
GeneralI do something like this,very good to use! Pin
lilyflower5-Aug-02 23:36
susslilyflower5-Aug-02 23:36 
Generala little change,but no twinkle(status bar) Pin
mclxly5-Dec-06 17:42
membermclxly5-Dec-06 17:42 
QuestionRe: I do something like this,very good to use! Pin
xu_qing14-Mar-07 7:15
memberxu_qing14-Mar-07 7:15 
AnswerRe: I do something like this,very good to use! Pin
The Code Machine21-Mar-07 16:10
memberThe Code Machine21-Mar-07 16:10 
GeneralRe: I do something like this,very good to use! Pin
rbrunton8-Feb-15 2:47
memberrbrunton8-Feb-15 2:47 
GeneralRe: What about SetPaneText() Pin
bkshrinivas7-Jun-04 2:45
memberbkshrinivas7-Jun-04 2:45 
AnswerRe: What about SetPaneText() Pin
Dbltrimmer30-Oct-05 8:36
memberDbltrimmer30-Oct-05 8:36 
GeneralVery very important, Onkar Singh tread this!!!! Pin
Anonymous4-Jun-02 13:06
memberAnonymous4-Jun-02 13: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.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 24 May 2002
Article Copyright 2002 by The Code Machine
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid