As Maarten says ...
TN := TreeView.Selected;
TN := TN.GetNext;
if TN <> nil then etc
.... works much faster.
> This works fine, except for one thing: the selected node
> is not marked as such in the list. I.e. you can not see
> in the list itself which is the selected node.
> There ought to be a trivial solution for it, but I can not find it.
Because your button is a TButton or a TBitBtn then the focus is moved
to the button when you click it. That removes the highlight from the
treeview unles you have set Treeview.HideSelection to false, or have
used a TSpeedButton. Setting Treeview.HideSelection to false leaves the
selection showing as grey when focus moves from the treeview.
- From: Tom de Neef