I need to do some custom painting and when an item in the custom control is pressed or hovered over I want to display the highlighted item state. PS. this is non-themed painting for Windows 2000 and high contrast (or when selected) on higher OS.
if (State != rsNormal)
{
Canvas->Brush->Color = clHighlight ;
Canvas->Font->Color = clWhite ; // clHightlightText ;
}
else
{
Canvas->Brush->Color = clBtnFace;
Canvas->Font->Color = clBtnText ;
}
Current code, above, works perfectly for my need but Font->Color
clwhite
is of course what I can see is the case in Win2K, WinXP etc. but it is not a system color and I fear there may be situations where clHighlight
may be a color that has not enough contrast with clWhite
.
The documentation mentions: clHightlightText
, which is basically what I need, yet my compiler C++ Builder 2009 doesn't know this system color and the fact that the documentation doesn't provide a link for it (different than the other colors) doesn't look good either.
How do I obtain a non-hard-coded value for the highlight text ?
clHighlightText
is the correct thing to use. It is defined in the same $(BCB)\include\vcl\Graphics.hpp
header file that defines all of the cl...
color constants, including the other ones you are using:
static const TColor clHighlight = -16777203;
static const TColor clHighlightText = -16777202;
static const TColor clBtnFace = -16777201;
...
static const TColor clBtnText = -16777198;
...
static const TColor clWhite = 16777215;
These constants have been around for a LONG LONG time, going back to the early C++Builder versions. Your version (CB2009) most definitely has them (the definitions above were copied from CB2009, in fact).