Click here to Skip to main content
13,900,891 members
Click here to Skip to main content
Add your own
alternative version


28 bookmarked
Posted 24 Aug 2007
Licenced CPOL

The Ultimate Toolbox Static Text Control

, 25 Aug 2007
Rate this:
Please Sign up or sign in to vote.
A customizable CStatic derived class from the Ultimate Toolbox

Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.

Source code and project files for this sample can be found in the samples\gui\StaticText directory of the sample projects download.


The COXStaticText class is a CStatic derived class. The normal look of this control is similar to a static control: it just sets a text string. However, unlike the MFC's CStatic, this class allows a user to give that text a special appearance.


  • Change the text color and background color
  • Set and get the text font and attributes
  • Draw 3D text (embossed text)
  • Draw 3D text (offset in pixels)
  • Scroll text in any direction
  • Set and get scrolling speed (in pixels per second)
  • Draw text at an angle
  • Draw ellipses at the beginning, end or middle of a text string
  • Draw special borders: sunken, raised, flat line, dotted line
  • Multi-threaded, consumes very little processor time when scrolling
  • The appearance of the COXStaticText control can be changed on the fly; a user can set any control property at any moment of time, and the result of this modification will be visible immediately
  • Text scrolling is carried out by a separate worker thread
  • The user can tune the text scrolling smoothness in order to minimize processor consumption


Create a static control on your CDialog based resource and assign it an ID. Using the Class Wizard or Add Member Variable wizard, add a CStatic member to the dialog class. Next, include the header OXStaticText.h, and change the CStatic member in the AXF_DATA section to a COXStaticText object. You may want to set up some initial properties in your OnInitDialog:

// Set the Static Text window.

LPTSTR    psText = _T("Static Text");
int        /*nTextLeft = 10, nTextTop = 10,*/ nTextHeight = 30;
m_StaticText.SetTextColor(RGB(0, 0, 0));
m_StaticText.SetBkColor(RGB(192, 192, 192));


Many other properties can be set as well, as outlined above. A complete class reference for the COXStaticText class can be found in the Graphical User Interface | Static Controls section of the compiled HTML help documentation.


Initial CodeProject release August 2007.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

459 members

You may also be interested in...


Comments and Discussions

Questionsource and doc download not available Pin
kyle.wu9-Mar-12 0:55
memberkyle.wu9-Mar-12 0:55 
GeneralDoesnt work in formview Pin
mhorowit1-Oct-07 19:21
membermhorowit1-Oct-07 19:21 
GeneralRe: Doesnt work in formview Pin
Tim Deveaux2-Oct-07 4:22
memberTim Deveaux2-Oct-07 4:22 
GeneralRe: Doesnt work in formview Pin
mhorowit2-Oct-07 9:26
membermhorowit2-Oct-07 9:26 
GeneralRe: Doesnt work in formview Pin
Tim Deveaux2-Oct-07 11:18
memberTim Deveaux2-Oct-07 11:18 
GeneralRe: Doesnt work in formview [modified] Pin
mhorowit4-Oct-07 9:46
membermhorowit4-Oct-07 9:46 
GeneralRe: Doesnt work in formview; fixed!!!! Pin
mhorowit4-Oct-07 10:40
membermhorowit4-Oct-07 10:40 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190306.1 | Last Updated 25 Aug 2007
Article Copyright 2007 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid