hopefully an easy question, but I could not find an answer. I am using Delphi TColor and some color values are negative. Is this documented? I need to do some color conversions, for example, to RGB.
for example: Label.Color=-16777188; //light bluish
Thanks
The negative values are not actual RGB colours, but Windows system colours, which are variable.
For instance, the following are actual RGB colours:
clRed = $000000FF; {00BBGGRR}
clBlue = $00FF0000;
clWhite = $00FFFFFF;
clBlack = $00000000;
Here are some system colours:
clWindow = $FF000005;
clWindowText = $FF000008;
clHighlight = $FF00000D;
clActiveCaption = $FF000002;
These are not actual RGB values, but represent your system colours. Often, clWindow
is white, clWindowText
is black, clHighlight
is some kind of blue etc., but -- again -- these settings can be changed in Windows.
When these 32-bit integers are interpreted as signed 32-bit integers, they become negative. That's what you are seeing:
clWindow = -16777211;
clWindowText = -16777208;
clHighlight = -16777203;
clActiveCaption = -16777214;
So in your case, -16777188 is not guaranteed to be "light bluish". In hex, this value is $FF00001C
and I recognize this as clGradientInactiveCaption
, that is, the second gradient colour of an inactive unthemed (Windows 9x-styled) window titlebar.
As you know, in the VCL you can use these system colours as if they were actual colours. But -- of course -- the actual colours you get might vary from user to user.
You can obtain an actual RGB colour from such a system colour by using the ColorToRGB
function. On my system, ColorToRGB(clGradientInactiveCaption)
yields $00F2E4D7
(indeed light bluish).