Strange. Your code is correct (except for the missing TreeView.Items.BeginUpdate/EndUpdate which makes population of the tree so slow), and I've used similar code many times myself.
The only reason I could imagine is that populating the tree and selecting one of the last nodes are too close together, maybe to prepare scrolling for such a long list of items - I don't know.
Having this in mind I moved the population code into the OnCreate handler of the form and selected the last node later into the OnActivate or OnShow event. This way it works...
procedure TForm1.PopulateTree;
begin
TreeView1.Items.BeginUpdate;
try
LoadFileTreeViewPath('C:\WINDOWS\System32\', TreeView1, nil, True);
finally
TreeView1.Items.EndUpdate;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FOnShowHandled := false;
PopulateTree;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
if not FOnShowHandled then
begin
TreeView1.Select(TreeView1.Items[TreeView1.Items.Count - 1]);
FOnShowHandled := true;
end;
end;
The boolean flag FOnShowHandled is supposed to prevent that the selection jumps to the end when OnShow is later executed again for some reason.