TColor to HTML color

Submitted by:David Villa

Date added:04 April, 2012

Category:Delphi

Delphi code example for TColor to HTML color

Tags: html color

Code Snippet:

procedure TForm1.Button1Click(Sender: TObject) ;

function ColorToHtml(DColor:TColor):string;
var
tmpRGB : TColorRef;
begin
tmpRGB := ColorToRGB(DColor) ;
Result:=Format('#%.2x%.2x%.2x',
[GetRValue(tmpRGB),
GetGValue(tmpRGB),
GetBValue(tmpRGB)]) ;
end; {function ColorToHtml}

begin
if ColorDialog1.Execute then
Label1.Caption:=ColorToHtml(ColorDialog1.Color) ;
end;
 
 

Comments