Recent

Author Topic: How to make network path available within the the TShellTreeView component?  (Read 2872 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
I use a TShellTreeView object in one of my programs that usefully traverses all drives and presents lists of folders for the user to select. I also have a way for the user to select UNC path, by using a simple text field.

However, a user has asked if it's possible to make the network space available within the the TShellTreeView component. So that in addition to C:, D:, there is also listed 'Network' and the machine names visible on that network beneath it, along with their respective shares beneath them.

Having explored the options of the component, I'm not sure it's there, but I wanted to know if anyone knew of a way, besides replacing the TShellTreeView component of my application with an OpenDialog dialog.

ASerge

  • Hero Member
  • *****
  • Posts: 2246
For Windows. ShellTreeView uses direct paths, but NetworkPlaces is a virtual directory that is populated by the system through IShellFolder. So there is no such possibility.
I can show you how to add a some directory as root to the ShellTreeView, and you can add a folders from the Network Shortcuts, for example.
Code: Pascal  [Select][+][-]
  1. type
  2.   TOpenShellTreeNode = class(TTreeNode) // Copied from ShellCtrls
  3.   private
  4.     FFileInfo: TSearchRec;
  5.     FBasePath: string;
  6.   end;
  7.  
  8. procedure AddToRoot(ToShellTree: TShellTreeView;
  9.   const Caption, Path: string; Data: Pointer = nil);
  10. var
  11.   RootNode: TOpenShellTreeNode;
  12.   RootDir: string;
  13. begin
  14.   RootNode := TOpenShellTreeNode(Pointer(
  15.     ToShellTree.Items.AddChildObject(nil, Caption, Data)));
  16.   RootDir := ExcludeTrailingPathDelimiter(Path);
  17.   RootNode.FFileInfo.Attr := FileGetAttr(RootDir);
  18.   RootNode.FFileInfo.Name := RootDir;
  19.   RootNode.FBasePath := '';
  20.   RootNode.HasChildren := True;
  21. end;

 

TinyPortal © 2005-2018