Funktioniert!
Aber nur etwa 200ms schneller (die 10.000ms sind damit aber knapp geknackt):
Hier nochmal die D5 Variante:
Delphi-Quellcode:
Function FindNodeByPath(const aTreeView: TTreeView; aPath: String): TTreeNode;
Var
Path: Array of String;
i: Integer;
Begin
Result := nil;
if aPath='' then exit;
//Path := Explode('\', ExcludeTrailingBackslash(aPath));
if aPath[Length(aPath)] <> '\' then aPath := aPath +'\';
while aPath <> '' do begin
i := Length(Path);
SetLength(Path,i+1);
Path[i] := Copy(aPath,1,Pos('\',aPath)-1);
Delete(aPath,1,Pos('\',aPath));
end;
If Path = nil Then Exit;
Result := aTreeView.Items.GetFirstNode;
i := 0;
While Assigned(Result) do Begin
If Result.Text = Path[i] Then Begin
If i < High(Path) Then Begin
Inc(i);
Result := Result.getFirstChild;
End Else Exit;
End Else Result := Result.getNextSibling;
End;
End;