Recent

Author Topic: TVirtualTreeView-Draw or string. Question about the Save and Load.  (Read 314 times)

jamie

  • Hero Member
  • *****
  • Posts: 6995
I have a question about this control, be it the laz version or before that.

We can talk about the LAZ version here since they are basically the same, for example the LazVirtualDrawTree!

These components have a Data field which you can specify to point to internal data of your own for each node and I would like to know exactly what gets saved and loaded when using the SaveTo and LoadFrom Stream or file?

 Does the Data at the end get written to the stream? In other words, does the complete node data long with the appending added info you specified?

 Let's assume for the time being this is what happens, I assume things like managed strings and Pointers to other items would not really work well if restored from a different session of the app?

 Am I on the write track here?

Jamie

The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6995
Re: TVirtualTreeView-Draw or string. Question about the Save and Load.
« Reply #1 on: May 30, 2025, 03:44:19 am »
Detailed help for this control is almost impossible to get. If it wasn't for the source code being there it would be just about useless.

 I had to sift through the sources to get a better understanding of what is happening here.

 When using the "SaveTostream", it writes a magicID at the start, something that is standard in many things like Image formats.

 The details for the nodes are written but if you have custom data that is sensitive to memory locations you can't be using any managed types in the Node record, which is an attachment to the end of the Record. What you can do is create your attachment, basically added fields that would indicate an Offset and size of your data so that it can be reloaded at a later date. No using absolute addresses unless this is data to be reloaded with the same session.

 The OnNodeSave event gets called after the Node record is written and that is when you write your custom data outwards, assuming the details of the info are properly up to date in node record because at this point that has already been written.
 etc.

Hope this helps anyone else, I am still sifting through it.
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6995
Re: TVirtualTreeView-Draw or string. Question about the Save and Load.
« Reply #2 on: May 30, 2025, 03:37:11 pm »
I wanted to drop another note and maybe this should be documented in the source code.

The OnSaveNode event gives you the Node for which you are currently using during the save process however, you must consider this as a read only item because making changes which you can at that point does not reflect what has already been written out.

 So, the node itself needs to be fully updated before this event is triggered.

 Placing a CONST Infront of the PVirtualNode in the event I don't think is going to disallow the access to the data member, but then again, I could be wrong there.

 Maybe someone can comment on this to restrict changing any members in the given node of this event, because like I said, changes do not reflect what has already been written to the stream.

Jamie

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018