|
|
Coloured controls
This is a bunch of subclassed controls, which paint the components in colours of your choice. Some of the classes stoop down to owner-drawn and custom-drawn techniques to achieve their goal, so even if you don't need cheery colours in your application, it might be worth a check.
Bringing on your own colours to the standard Windows controls seems terrible
awkward. Almost all of the controls support some form or another of changing
its default colouring, but it's only with the latest Windows Common Controls
that we actually see a simple API emerging, such as the The list of controls included in this package:
How they workIt's straight-ahead. Just add them as any other subclassed WTL control.Add a member variable to your dialog implementation file; pick the class that extends your dialog element.
In the OnInitDialog() event handler, add the following lines:
Add the following reflection macro to your dialog's message map:
Then use the SetXXXColor() methods to change the colours.
Construct a COLORREF colour using the RGB(r,g,b) macro.
To use the default (Windows system) colour, specify -1 (or CLR_INVALID).
If the method takes two arguments, then the first is usually the text colour and the second is the background. Each control supports different kinds of colouring. Some have colours specific for a disabled state, a few allow you to specify the colours when an item is selected, the Edit control has a special Read Only state and so on...
None of the Windows controls seems to allow overriding the disabled text colour. Perhaps because Bill Gates prefers to use the GrayString() API internally. Some of the newer
Common Controls will not allow you to change the colour of the selected
item box either. This is a pity.
I'm not sure how these controls will look in Windows XP. With the new theme painting and all, perhaps they are not looking so cool. NotesNote the consistent use of the English spelling of colours in
this article just to annoy my American friends.
![]() Source Code DependenciesMicrosoft Visual C++ 6.0Microsoft WTL 3.1 Library Download Files
Written by Bjarke Viksoe. Article submitted 2/28/2002. To the top
|
|||