Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

XColorStatic - a colorizing static control

0.00/5 (No votes)
16 Oct 2003 1  
XColorStatic is a simple CStatic-based control that provides font changes, text and background colors, and icon display.

Introduction

XColorStatic is a general-purpose control to allow nice text display on a dialog. The demo shows you the kinds of text and icon display that are possible:

screenshot

XColorStatic API

Here is the complete list of CXColorStatic methods:

    void SetBackgroundColor(COLORREF rgb, BOOL bRedraw = TRUE);
    void SetTextColor(COLORREF rgb, BOOL bRedraw = TRUE);
    void SetBold(BOOL bFlag, BOOL bRedraw = TRUE);
    void SetFont(LPCTSTR lpszFaceName, int nPointSize, BOOL bRedraw = TRUE);
    void SetFont(LOGFONT *pLogFont, BOOL bRedraw = TRUE);
    void SetFont(CFont *pFont, BOOL bRedraw = TRUE);
    void SetIcon(HICON hIcon, BOOL bRedraw = TRUE);
    void SetMargins(int x, int y) { m_nXMargin = x; m_nYMargin = y; }

How To Use

To integrate XColorStatic into your app, you first need to add the following files to your project:

  • XColorStatic.cpp
  • XColorStatic.h
  • FontSize.cpp
  • FontSize.h

Then use the resource editor to add a static control to your dialog, and use Class Wizard to attach a member variable to that control. Note that when adding the static control, you must name it something other than IDC_STATIC.

Next, include the header file XColorStatic.h in the dialog's header file. Then replace the CStatic definition with CXColorStatic. Now you are ready to start using XColorStatic.

Usage

This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.

Revision History

Version 1.0 - 2003 October 17

  • Initial public release.

License

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