Enhanced statusbar class

Displays horizontally scrolling text, vertically scrolling text, changing fonts for each status bar pane, changing font colors for each status bar pane, changing background colors for each status bar pane, displaying a bitmap banner across the status bar.

I was recently involved in a project that required colors along the status bar (basically, an owner-drawn status bar). Although the requirement stopped at colors in certain panes, I went all out and created a class derived from CStatusBar. My new class (CColorStatusBar) allows for different fonts in each pane, different text colors, different background colors, horizontally scrolling text, vertically scrolling text, diagonally scrolling text (I don't know a use for diagonally scrolling text, but it's fun to watch for a minute), and tiling a bitmap across the status bar - excellent for identifying your software as BETA. I tried to create the new class to be as close to a drop-in replacement for CStatusBar as possible, but in order to customize each pane, I had to force a small amount of extra initialization in CMainFrame (or the owner of the status bar).

To exploit the capabilities of the status bar, double-click on a status bar pane to activate the Status Bar Pane Properties. The dialog will allow you to toggle the status bar banner, transparent text, horizontal and vertical scrolling, window pane font, font color, etc. The most remarkable code block is contained in the header file ColorStatusBar.h and implementation file ColorStatusBar.cpp. Contained in these files are the classes CStatusPaneInfo and CColorStatusBar. CStatusPaneInfo contains information specific to a single status bar window pane. Items such as background color, foreground color, horizontal and/or vertical scrolling, pane font, etc. CColorStatusBar keeps an accounting of the status bar window pane information structures through the use of the CObList. Scrolling is accomplished through the use of a timer and a CPoint which remembers the last upper-left position of the previous DrawText call.

Warning: There is a small amount of additional processing that needs to be accomplished during creation of the status bar in MainFrm.cpp. Basically, the CStatusPaneInfo objects need to be created for use by the OnPaint method in the status bar.

Download project files 35KB


  • what is a status bar?

    Posted by Legacy on 01/05/2003 12:00am

    Originally posted by: Henz

    Isn't it the 'bar' at the base of an sdi/mdi app?

  • how to put my dialogbar into status bar?

    Posted by Legacy on 04/30/2001 12:00am

    Originally posted by: alwaysky

    I try to put my dialogbar into status bar....
    but I can't do it

    First of All, I can't decide point to create dialogbar
    ,because there is not a funtion in CDialogBar::Create.

    plz help me

  • Windows scrolling text prob....

    Posted by Legacy on 04/15/1999 12:00am

    Originally posted by: Jim Carr

    Hello. This is a great site First of all! ;> I just wanted to know, a few of us are designing a game for windows. We are having a problem with the scrolling text. I'm not the programming person..so all i have is what he told me....this is what he asks....

    "...we're looking for sample code for manual word wrap and manual horizontal autoscrolling text on a direct X surface or embeded in our window (front end)..."

    I'm just wondering if this page is what i'm looking for? Will the code above help me? Can anyone help me?? :) Thanks a ton in advance!!!


  • A bug with horizontal scrolling fixed

    Posted by Legacy on 04/09/1999 12:00am

    Originally posted by: Zemskov Dmitry

    I noticed a bug with horizontal scrolling:
    1) When the scrolling text is longer than the pane, the tail of the text is not displayed.
    2) When the scrolling text is shorter than the pane, there is a delay between disappearing of the last symbol of the text and appearing of the first symbol of the new text (No one could explain better :-)
    To avoid this I inserted these two lines of code :-) into ColorStatusBar.cpp right before the line 379 ( // if we don't have any visible text ):

    // Ajust the right side of the rectangle so that it bounds the last character in the line
    memDC.DrawText(str, rect, DT_LEFT | DT_CALCRECT );

    Now it seems to work OK.

  • FYI: BoundsChecker reports dangling pointers

    Posted by Legacy on 03/08/1999 12:00am

    Originally posted by: Dave Richter

    BoundsChecker v6.0 under both MSVC++ 5.0 & 6.0 reports dangling
    pointers whenever graypen is referenced in ColorStatusBar.cpp.
    By creating the pen on the stack once and using CreatePen() and
    DeleteObject(), I was able to get past these warnings. Just
    thought you might want to know.

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

Top White Papers and Webcasts

  • Thanks to wide spread cloud hosting and innovations small businesses can meet and exceed the legacy systems of goliath corporations. Explore the freedom to work how you want, with a phone system that will adapt to your evolving needs and actually save you lots of expense—read Get an Enterprise Phone System without High Cost and Complexity. The article clearly illustrates: The only hardware you'll need is phone equipment for advanced voice and fax. How to join all your employees, mobile devices, …

  • Do you spend a lot of time thinking about your enemies? Attacker attribution - figuring out who's out to get you - is one of the most important things an organization can do to protect itself.  Because you have no hope of defending yourself if you don't understand who the attackers are. Good news? Every organization isn't targeted by all the attackers. Bad news? No one can identify your potential attackers as well as you. Read this graphics-rich threat summary for 2014 to determine who might be your next …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date