function GetContrastingColor(Color: TColor): TColor;
begin
Color := ColorToRGB(Color); // convert system-defined colors
if (Color+Color shr 8+Color shr 16) and $0000FF>= $180 then
Result := clBlack
else
Result := clWhite;
end;
function GetContrastingColor(Color: TColor): TColor;
begin
Color := ColorToRGB(Color); // convert system-defined colors
Result :=
(Color+$000080) and $0000FF+ // red component
(Color+$008000) and $00FF00+ // green component
(Color+$800000) and $FF0000; // blue component
end;