OnDelete würde doch auch reichen?
Delphi-Quellcode:
// TreeView.OnDeletion
Procedure TForm1.TreeView1Deletion(Sender: TObject; Node: TTreeNode);
Begin
If Assigned(Node.Data) Then Dispose(PNoteRec(Node.Data));
End;
New(NoteRecPtr);
NoteRecPtr.Caption := 'XYZ';
NoteRecPtr.ID := 'XYZ';
NewNode := TV.Items.AddChildObject(TV.Items[0], 'XYZ', NoteRecPtr);
oder man überläßt die Speicherverwaltung komplett dem TreeView
Delphi-Quellcode:
// TreeView.OnAddition
Procedure TForm1.TreeView1Addition(Sender: TObject; Node: TTreeNode);
Begin
New(PNoteRec(Node.Data));
End;
// TreeView.OnDeletion
Procedure TForm1.TreeView1Deletion(Sender: TObject; Node: TTreeNode);
Begin
Dispose(PNoteRec(Node.Data));
End;
NewNode := TV.Items.AddChild(TV.Items[0], 'XYZ');
PNoteRec(NewNode.Data).Caption := 'XYZ';
PNoteRec(NewNode.Data).ID := 'XYZ';