Recent

Author Topic: Save form objects using XML  (Read 3059 times)

Gary Randall

  • Jr. Member
  • **
  • Posts: 70
Save form objects using XML
« on: July 29, 2014, 06:19:46 pm »
I'm using TStringgrid and instantiating objects (notes, labels, shapes, etc.) during program execution.  The stringgrid.SaveToFile works beautifully for saving and restoring the grid and cell contents, but doesn't save the created objects.  Is there a similar way to save created objects from the form?  I have not yet discovered where the object info is stored.  It should be accessible from the program, but I'm not finding it.  If not, I'm guessing I can create a set of object names as they are created, and append the object properties to the XML file created by stringgrid.  Then I can create an XML restore procedure to import the saved data.  The objects are children of the grid and need to be restored to their grid locations.  I will be taking a look at the SaveToFile procedure to get some ideas, but thought I'd ask the experts first. 

Any suggestions will be greatly appreciated.  I have "Learning to Program Using Lazarus" and "Lazarus The Complete Guide" so I just need a gentle nudge in the right direction.  Thanks,

Gary
Windows 7 Home Premium 64 bit - SP 1
Lazarus Version #: 1.8.0; FPC Version: 3.0.4
SVN Revision 56594
i386-win32-win32/win64

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: Save form objects using XML
« Reply #1 on: July 29, 2014, 06:30:36 pm »
Hi,
I think you should look at here: http://wiki.freepascal.org/Streaming_components
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Save form objects using XML
« Reply #2 on: July 29, 2014, 06:39:07 pm »
Also look at the included example project at
.../lazarus/exmples/componentstreaming/componentstreaming.lpi

The only component data that can be saved and restored is published data (public property data is not stored).
The main unit that provides the methods used to save and restore persistent component data is called LResources. You will need to study its code.

Gary Randall

  • Jr. Member
  • **
  • Posts: 70
Re: Save form objects using XML
« Reply #3 on: July 29, 2014, 10:55:26 pm »
Thank you, gentlemen.  That's just what I needed.  I can see my controls now.  I should have realized they had to be published.  Now I just need to play with streaming.  I was hoping for something as simple as SaveToFile for the controls, but I now see how to approach it.

Gary
Windows 7 Home Premium 64 bit - SP 1
Lazarus Version #: 1.8.0; FPC Version: 3.0.4
SVN Revision 56594
i386-win32-win32/win64

 

TinyPortal © 2005-2018