--> Color Converting HTML to TColor in delphi | Delphi Tips Trick

For Newbie

Tuesday, 15 November 2011

Color Converting HTML to TColor in delphi

| Tuesday, 15 November 2011


Function for converting HTML color (hex) to TColor

Function Declaration:
HkeTColor function (wHTML: string): TColor;
begin
   Result: = StringToColor ('$' + Copy (wHTML, 6, 2) + Copy (wHTML, 4, 2) +
             Copy (wHTML, 2, 2));
end;

Example of implementation:
Shape1.Brush.Color: = HKeTColor ('# DFDFDF');

Example # 2:
procedure TForm1.Button1Click (Sender: TObject);
begin
   try
     Shape1.Brush.Color: = HKeTColor (Edit1.Text);
   except
     ShowMessage ('INVALID');
   end;
end;

Related Posts

No comments: