[fpc-pascal] ObjectBinaryToText - how to write only selected property?

Martin Schreiber mse00000 at gmail.com
Sun May 6 09:15:30 CEST 2012


On Saturday 05 May 2012 18:15:51 Krzysztof wrote:
> Hi,
>
> ObjectBinaryToText method can save object structure to string, but how
> save only some propertys? I could use RTTI and TypeInfo, but
> ObjectBinaryToText can parse property hierarchy
> (Propery1.Subproperty1.Color etc). Or how I can save and read object
> from string without object name?
> Example: I am creating simple theme manager which save settings of
> some control (e.g. TEdit) and must read it not paying attention to the
> component name (Edit1, Edit2, Edit3 etc...) Must work like a template.
>
tskinmanager of MSEgui does something similar, see 
lib/common/kernel/mseskin.pas.
Every MSEgui component has the procedure updateskin() which normally will be 
called after loading the form. tmsecomponent.updateskin() calls the global 
oninitskinobject handler which is assigned to the active <tskincontroller> 
which updates the default values of the component according to the skin 
settings. Values which are already set by the form resources normally are not 
changed so it is possible to define component specific exceptions to the 
current theme, for instance a specific color, frame or font.

objectbinarytotext() converts from binary streamed data written by twriter to 
a human readable text representation, it does not scan the properties, 
twriter.writeproperties() does this. The whole Delphi/FPC component streaming 
system is very locked because of the many private fields and procedures. I 
think it is difficult to use it as base for your undertaking.

Martin



More information about the fpc-pascal mailing list