Doing it by hand is certainly an option.
What I had in mind though ... I use IterateSubtree much, but I guess I am out of luck with deletes, since IterateSubtree relies on the tree's GetNextChild and GetNextSibling functionality, which is broken as soon as I delete a node from inside the IterateSubtree callback. What I dream of (for code readibllity's sake ...) is beeing able to do something like
for n in VST.SelectedNodes do
VST.DeleteNode(n);
...
or VST.IterateSubtree(VST.RootNode,@DeleteIfMatches,nil);
where DeleteIfMatches checks the Node and does the delete if applicable.
Currently I am testing this:
function VTVIterateSubtree(Sender: TBaseVirtualTree; ParentNode: PVirtualNode; Callback: TVTGetNodeProc;
Data: Pointer): PVirtualNode;
var
CurrentNode, NextNode: PVirtualNode;
abort: boolean;
begin
Result := nil;
assert(assigned(ParentNode), 'VTVIterateSubtree: Node is undefined.');
if Assigned(ParentNode) then
begin
CurrentNode := Sender.GetFirstChild(ParentNode);
while assigned(CurrentNode) do
begin
NextNode := Sender.GetNextSibling(CurrentNode);
Abort := False;
if assigned(CallBack) then Callback(Sender, CurrentNode, Data, Abort);
if abort then exit(CurrentNode);
// traverse into subtrees
result := VTVIterateSubtree(Sender, CurrentNode, Callback, Data);
CurrentNode := NextNode;
end;
end;
end;