Ultimate Pack

Color to string and vice versa - Algorithms - Tips & Tricks - Greatis Delphi Pages

Use StringToColor and ColorToString functions. These functions are undocumented and contained in graphics module.
Notes:
ColorToString - if value has a special name, then this name will be display. For example, $FFFFFF - is a clWhite.
StringToColor - you may use name of color here. For example, Str:='clYellow'.

procedure TForm1.Button1Click(Sender: TObject);
var
  Str:string;
begin
  Str:='$AC142F';
  Form1.Color:=StringToColor(Str);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Label1.Caption:=ColorToString($FFFFFF);
end;
For more
Delphi Help

Download source


Delphi books recommended by Amazon.com

More Delphi programming books on Amazon.com


Copyright © 1998-2014 Greatis Software