Gradient Label control

Gradient Label control

This article was submitted .

The Gradient Label control is a subclassed STATIC Windows control, which paints the background with the same gradient colors as the window caption in Windows 98 or Windows 2000.

To use it, place a static control (label) on your dialog. Make sure to enter a caption.
Add a member variable to your dialog implementation file...

CGradientLabelCtrl m_ctrlLabel
In the OnInitDialog() event handler, add the following line:
LRESULT OnInitDialog(UINT /*uMsg*/, 
                     WPARAM /*wParam*/, 
                     LPARAM /*lParam*/, 
                     BOOL& /*bHandled*/)

If you need to paint with a different color, the control can easily be tweaked to do so. A number of internal properties can already be set to change the control's appearance. One of them will paint the gradient colors vertically instead of horizontally.

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft WTL 3.0 Library

Download Files

DownloadSource Code (3 Kb)