Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-04

How to stream TColor in hexadecimal format?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vojtěch Čihák

Hello,
?
how to stream TColor in hexadecimal format?
?
Currently, TColor is streamed as
?
Color = 5810431
Color = clTeal
?
in *.lfm or
?
<integer name="ClrDWBCurve" value="33023"/>
<ident name="ClrSF2Curve" value="clRed"/>
?
in *.xml.
How can I stream it in $00FEDCBA format?
?
In the worst case, I probably can move those?properties?from published to public and TPersistent.DefineProperties. Will it work? Or is there some more elegant way?
?
Thanks for help, V.

Reply by email

Mattias Gaertner
to Vojtěch Čihák
Show quoted text 9 lines
[...] how to stream TColor in hexadecimal format? ? Currently, TColor is streamed as ? Color = 5810431 Color = clTeal ? in *.lfm or

As far as I know the underlying TAbstractObjectWriter does not support hexadecimal.

?

Show quoted text 8 lines
<integer name="ClrDWBCurve" value="33023"/> <ident name="ClrSF2Curve" value="clRed"/> ? in *.xml. How can I stream it in $00FEDCBA format? ? In the worst case, I probably can move those?properties?from published to public and TPersistent.DefineProperties. Will it work?

No, because that uses TAbstractObjectWriter too.

Or is there some more elegant way?

Maybe you can overload
RegisterIntegerConsts(TypeInfo(TColor), TIdentToInt(@IdentToColor), TIntToIdent(@ColorToIdent));
with your own functions and write colors as "h00FEDCBA".

Mattias

Reply by email

Vojtěch Čihák
to Mattias Gaertner

Thanks,
?
it does not work. Where should I place such overloaded procedure? ?
The reason I need it is that the *.xml file is config file so there is a chance that someone will edit it manually. Or there is possibility to change declaration from TColor to string. ?
V.
______________________________________________________________

Od: Mattias Gaertner Komu: Datum: 14.04.2015 02:09 P?edm?t: Re: [Lazarus] How to stream TColor in hexadecimal format?

Maybe you can overload
?RegisterIntegerConsts(TypeInfo(TColor), TIdentToInt(@IdentToColor), TIntToIdent(@ColorToIdent));
with your own functions and write colors as "h00FEDCBA".

Mattias

Reply by email