List Info

Thread: Typecast




Typecast
user name
2006-08-22 16:21:39

Brigitte,

> How can I convert a string like 'Color [A=255, R=207, G=219, B=235]' into
> a
> System.Drawing.Color object? I'm trying to allow the user to set their
>; background colour by writing to and reading from the registry.

I do not know the objects or properties you are accessing here, but I assume
that Color has the type TColor.

If so, you could write a short routine to parse the string and get the R, G,
and B values out of the string. Then use the RGB function (in Windows.pas)
to convert those three integer values into one TColor value. Then assign
that value to your Color property.

If you can be sure the string is formatted properly, writing the routine
would be pretty easy. But you surely need something more sophisticated than
a typecast.

Rory Daulton
rorydaultonemail.com

----------------------------------------------------------
[This e-mail scanned for viruses and spam by Nmax - "Your MAXimum Connection!"]

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )