[fpc-pascal] Is there a smart way to save/restore NotifyEvents and objects?

Dennis Poon dennis at avidsoft.com.hk
Sat Feb 3 06:55:50 CET 2018



Sven Barth via fpc-pascal wrote:
> Am 02.02.2018 17:53 schrieb "Dennis" <dec12 at avidsoft.com.hk 
> <mailto:dec12 at avidsoft.com.hk>>:
>
>     I have list of objects which contains references to other objects.
>     I need to save all these objects to harddisk to be restored on a
>     latter day.
>
>     I know how to stream the data fields of these objects to a
>     TFileStream but the tricky part is these how to restore the object
>     references.
>
>     The only way I can think of is to assign unique IDs to each
>     objects and store these IDs to file.
>     When these objects are later restored, I used these IDs find the
>     actual objects and re-assign them back to the object references.
>
>     It is tedious. Is there a smarter way?
>
>     Also, there are some TNotifyEvent fields  e.g. OnClick, OnClose
>     etc.  How do I save and restore them from file?
>
>     Many thanks in advance.
>
>
> If your objects inherit from TComponent and you use published 
> properties you can use the streaming screen of the RTL.
>
I am curious how TComponent save and restore TnotifyEvent fields. Can 
you explain a little bit?
Also, what is 'streaming screen' of RTL? How to use it?

Thanks.

Dennis




More information about the fpc-pascal mailing list