Colored Static Controls


CColorStaticST is a class derived from MFC CStatic class.

This class lets put static controls inside your applications
and easly make them colored or even blinking!
CColorStaticST image

CColorStaticST features:

  • Standard CStatic properties
  • Customizable background color
  • Customizable text color
  • Background color can blink
  • Text can blink
  • Notification message can be sent on rising blinks
  • Written in Visual C++ v5.0
  • Full source code included!
  • It’s free!

You are encouraged to use this class everywhere you want; there is no fee
required for CColorStaticST. Freely add modifications and/or fix bugs, but please,
send any of these to SoftechSoftware!

How to integrate CColorStaticST in your application

In your project include the following files:


With dialog editor create a static text called, for example, IDC_DANGER
and create a member variable for it:

   CColorStaticST m_stcDanger;

Now attach the static text to CColorStaticST. In your OnInitDialog procedure:

   // Call the base method

   // Create the IDC_DANGER text
   m_stcDanger.SubclassDlgItem(IDC_DANGER, this);

By default the static text will have the standard system colors. Both
text and backgroud color can be customized:

   // Change the text color to White
   m_stcDanger.SetTextColor(RGB(255, 255, 255));
   // Change the background color to Green
   m_stcDanger.SetBkColor(RGB(0, 255, 0));

The text and/or the background can blink! Two colors must be
supplied for text and background blinks. First color will be
used for blink OFF state and second color for blink ON state (called also rising blink):

   // Set blink colors for text
   m_stcDanger.SetBlinkTextColors(RGB(128, 0, 0), RGB(255, 255, 255));

   // Set blink colors for background
   m_stcDanger.SetBlinkBkColors(RGB(128, 0, 0), RGB(255, 0, 0));

   // Start text blinking
   m_stcDanger.StartTextBlink(TRUE, CColorStaticST::ST_FLS_FAST);

   // Start background blinking
   m_stcDanger.StartBkBlink(TRUE, CColorStaticST::ST_FLS_FAST);

CColorStaticST can send a message to the parent window each time it has a
rising blink. To do this a user defined message and a parent window must be

   // Enable notification message
   m_stcDanger.EnableNotify(this, WM_USER + 10);

Your static text is now a CColorStaticST!

Look inside the demo program to learn more about CColorStaticST. This is the best way!

CColorStaticST members

void SetTextColor(COLORREF crTextColor = 0xffffffff);

Set color for text (when not blinking)
Input values:

  • crTextColor

    The new text color


m_stcDanger.SetTextColor(RGB(255, 255, 255));

m_stcDanger.SetTextColor(); // To restore the default system color

COLORREF GetTextColor();

Get current text color

COLORREF crRetValue = m_stcDanger.GetTextColor();

void SetBkColor(COLORREF crBkColor = 0xffffffff);

Set color for background (when not blinking)
Input values:

  • crBkColor

    The new background color


m_stcDanger.SetBkColor(RGB(255, 0, 0));

m_stcDanger.SetBkColor(); // To restore the default system color

COLORREF GetBkColor();
Get current background color


COLORREF crRetValue = m_stcDanger.GetBkColor();

void SetBlinkTextColors(COLORREF crBlinkTextColor1, COLORREF crBlinkTextColor2);

Set colors for text (when blinking)

Input values:

  • crBlinkTextColor1

    Text color for blink OFF state
  • crBlinkTextColor2

    Text color for blink ON state (rising blink)


m_stcDanger.SetBlinkTextColors(RGB(128, 0, 0), RGB(255, 255, 255));

void StartTextBlink(BOOL bStart = TRUE, UINT nElapse = ST_FLS_NORMAL);

Start/stop text blinking

Input values:

  • bStart

    TRUE starts blinking

    FALSE stops blinking

  • nElapse

    Defines the text blinking intervall. Possible values are:

    ST_FLS_SLOW (2000 ms)

    ST_FLS_NORMAL (1000 ms)

    ST_FLS_FAST (500 ms)


m_stcDanger.StartTextBlink(TRUE, CColorStaticST::ST_FLS_FAST);

m_stcDanger.StartTextBlink(TRUE, 250); // To blink with custom intervall

m_stcDanger.StartTextBlink(); // To stop blinking

void SetBlinkBkColors(COLORREF crBlinkBkColor1, COLORREF crBlinkBkColor2);

Set colors for background (when blinking)

Input values:

  • crBlinkBkColor1

    Background color for blink OFF state
  • crBlinkBkColor2

    Background color for blink ON state (rising blink)


m_stcDanger.SetBlinkBkColors(RGB(128, 0, 0), RGB(255, 0, 0));

void StartBkBlink(BOOL bStart = TRUE, UINT nElapse = ST_FLS_NORMAL);

Start/stop background blinking

See StartTextBlink for possible input values


m_stcDanger.StartBkBlink(TRUE, CColorStaticST::ST_FLS_FAST);

m_stcDanger.StartBkBlink(TRUE, 250); // To blink with custom intervall

m_stcDanger.StartBkBlink(); // To stop blinking

void EnableNotify(CWnd* pParent = NULL, UINT nMsg = WM_USER);

Enable/Disable sending notification message on rising blinks

Input values:

  • pParent

    Parent window of the static text
  • nMsg

    Message to send


m_stcDanger.EnableNotify(this, WM_USER + 10);

m_stcDanger.EnableNotify(); // To disable message sending

static const short GetVersionI()

static const char* GetVersionC()

Return CColorStaticST version


int nVer = CColorStaticST::GetVersionI(); // Divide by 10 to get actual version

char szVer[20];

strcpy(szVer, CColorStaticST::GetVersionC());

Download the demo project (99Kb).


  • CColorStaticST v1.0

    First release

Things to do

  • Any suggestion?

Contact addresses

SoftechSoftware E-Mail:

[email protected]

SoftechSoftware homepage:

CColorStaticST homepage:

More by Author

Must Read