Save Nodes from a VirtualTree
Posted on 2010-01-02
I am trying to save the node data in a VirtualTree, so I can load the data back after the applications restarts. Saving the GroupName from the record is causing problems. This is with Delphi 2010 and the latest VST.
// this is a record structure for the virtual treeview to hold the object
PTVgrplst = ^RTVgrplst;
RTVgrplst = record
procedure TFormMain.VTreeGroupsSaveNode(Sender: TBaseVirtualTree;
Node: PVirtualNode; Stream: TStream);
Data := VTreeGroups.GetNodeData(Node);
len := Length(Data.GroupName);
Stream.Write(Data.GroupName, Len); <<--
If I add like 100 to the "Len" like so...
then I can see the GroupName string in the dat/textfile that I save the contents to... but if I dont then the groupname isnt saved to the file (cut off actually, not missing). When I log the data, GroupName is not "" and the length is correct too. But why isnt the stream saving it correctly?