Tuesday, 15 November 2011
Home »
Tips and Trick Delphi
» Color Converting HTML to TColor in delphi
Color Converting HTML to TColor in delphi
To Share | 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;
No comments:
Post a Comment