- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Converting a TColor value to a HTML Color string

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;




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile