Click here to Skip to main content
Click here to Skip to main content

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

Comments and Discussions

GeneralMy vote of 3 Pinmemberwolfgangpuelm29-Sep-10 5:46 
GeneralRe: My vote of 3 PinmemberThe Code Machine13-Oct-10 19:39 
QuestionDear Pinmemberteth3-Feb-08 22:13 
GeneralChange Color based on Error PinmemberNYTSX3-May-06 4:32 
GeneralRe: Change Color based on Error PinmemberThe Code Machine24-Aug-06 6:18 
GeneralBrilliat !! PinmemberAlton Williams21-Jun-05 2:53 
GeneralResource problem Pinmembershrinivasbk7-Jul-04 1:37 
QuestionHow to add to Dialog Box Pinmembermistroseth7-Apr-03 9:57 
GeneralI have completed it, and it works well with SetPaneText member function Pinmembercadinfo10-Nov-02 2:32 
GeneralRe: I have completed it, and it works well with SetPaneText member function Pinmembervikas amin25-Aug-05 23:41 
QuestionWhat about SetPaneText() Pinmemberspentaro15-Jul-02 19:41 
AnswerRe: What about SetPaneText() PinmemberOnkar Singh15-Jul-02 20:53 
GeneralRe: What about SetPaneText() PinsussJ. Spencer Greene16-Jul-02 8:30 
GeneralRe: What about SetPaneText() PinmemberOnkar Singh16-Jul-02 20:53 
GeneralI do something like this,very good to use! Pinsusslilyflower5-Aug-02 22:36 
Generala little change,but no twinkle(status bar) Pinmembermclxly5-Dec-06 16:42 
QuestionRe: I do something like this,very good to use! Pinmemberxu_qing14-Mar-07 6:15 
AnswerRe: I do something like this,very good to use! PinmemberThe Code Machine21-Mar-07 15:10 
GeneralRe: What about SetPaneText() Pinmemberbkshrinivas7-Jun-04 1:45 
AnswerRe: What about SetPaneText() PinmemberDbltrimmer30-Oct-05 7:36 
GeneralVery very important, Onkar Singh tread this!!!! PinmemberAnonymous4-Jun-02 12:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web04 | 2.8.140709.1 | Last Updated 24 May 2002
Article Copyright 2002 by The Code Machine
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid