Главная страница | назад





Article #16878: Converting a TColor value to a HTML Color string

 Question and Answer Database
FAQ1878D.txt — Converting a TColor value to a HTML Color string
Category :Internet/WEB
Platform :All-32Bit
Product :
Question:
How can I convert a TColor value to a HTML Color string?
Answer:
The following example demonstrates converting a TColor to
a RGB color, and formating the RGB color to be shown as
hexadecimal digits.
procedure TForm1.Button1Click(Sender: TObject);
var
TheRgbValue : TColorRef;
begin
if ColorDialog1.Execute then begin
TheRgbValue := ColorToRGB(ColorDialog1.Color);
ShowMessage(Format('%.2x%.2x%.2x',
[GetRValue(TheRGBValue),
GetGValue(TheRGBValue),
GetBValue(TheRGBValue)]));
end;
end;
4/2/99 11:46:48 AM

Last Modified: 01-SEP-99