Recent

Author Topic: TShellTreeView and FindNodeWithTextPath  (Read 973 times)

valter.home

  • Jr. Member
  • **
  • Posts: 81
TShellTreeView and FindNodeWithTextPath
« on: April 25, 2021, 06:01:41 pm »
I have a TShellTreeView in which I allow the user to create and delete folders.
When one of these operations is performed I perform an update of TShellTreeView so that it shows the changes just made.
In the case of creating a new folder to update the list I find the parent of the node that the user has chosen to create a new folder, I collapse it and expand it again, then I set the new folder created as "selected".

Code: Pascal  [Select][+][-]
  1. var
  2.   UserName, s: string;
  3.   FParent, FChild: TTreeNode;
  4.  
  5. UserName:=NewNameFolder;
  6.  
  7. [create new folder...]
  8.  
  9. ShellTreeView.BeginUpdate;
  10. FChild:=ShellTreeView.Selected;
  11. if FChild.Text <> ShellTreeView.Root then
  12.   Fparent:=Fchild.Parent
  13. else
  14.   Fparent := ShellTreeView.Items[0];
  15.  
  16. FParent.Expanded:=false;
  17. FParent.Expanded:=true;
  18. FChild.Expanded:=true;
  19.  
  20. s:=FChild.GetTextPath+'/'+UserName;
  21. ShellTreeView.Selected:=ShellTreeView.Items.FindNodeWithTextPath(s);
  22.  
  23. ShellTreeView.EndUpdate;

What is not clear to me is why GetTextPath or FindNodeWithTextPath returns the PathDelim as slash instead backslash?
For example if ShellTreeView.Root = c:\ MyFolder all added folders are displayed as c:\MyFolder/NewFolder/NewFolder2

Under Windows can any inconveniences occur?





wp

  • Hero Member
  • *****
  • Posts: 13625
Re: TShellTreeView and FindNodeWithTextPath
« Reply #1 on: April 25, 2021, 06:56:01 pm »
This is because these methods are introduced by the ancestor of TShellTreeView, TCustomTreeView, and this are valid in a more general sense.

In case of TShellListView the recommended way to list a path is the method GetPathFromNode(ANode) which does use the correct directory separators.

 

TinyPortal © 2005-2018