Delphi, VirtualStringTree - classes (objects) instead of records?

Setup datasize for holding object vstTree. NodeDataSize := SizeOf(TMyObject); Get the datasize holder and bind to your object vstTree. GetNodeData(passed in interested node)^ := your object or vstTree.

GetNodeData(vstTree. AddChild(nil))^ := TMyObject. Create; or use vstTree.

InsertNode method To free the binding object hookup the OnFreeNode event vstTree. OnFreeNode := FreeNodeMethod; with procedure TFoo. FreeNodeMethod(Sender: TBaseVirtualTree; Node: PVirtualNode); var P: ^TMyObject; begin P := Sender.

GetNodeData(Node); if P nil then begin P^. Free; P^ := nil; //for your safety or you can omit this line end; end.

You could create the object instance after receiving the node data, as in : fNd:= vstTree. GetNodeData(vstTree. AddChild(nil)); fnd.

Obj := TMbyObject. Create; or you could try and assign it directly Pointer(Obj) := vstTree. GetNodeData(...).

And you can free your object in OnFreeNode event.

This should be a comment to Aldo's answer. – Smasher Feb 18 '10 at 22:08.

Just add an object reference to your record. Use the OnInitNode and OnFreeNode events to create and destroy your object.

The following code doesn't compile: vstTree. GetNodeData(passed in interested node)^ := your object or vstTree. GetNodeData(vstTree.

AddChild(nil))^ := TMyObject. Create; Not at least in Delphi 2007. The following error pops up: "E2015 Operator not applicable to this operand type".

PS: I tried to post this as a comment to APZ28 but the link to comment wasn't avaiable.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions