On 4/6/13, Bart <[email protected]> wrote:
> Attached a new patch.

This time with the patch ;-)

Bart
Index: /devel/lazarus/lcl/shellctrls.pas
===================================================================
--- /devel/lazarus/lcl/shellctrls.pas	(revision 40594)
+++ /devel/lazarus/lcl/shellctrls.pas	(working copy)
@@ -337,6 +337,8 @@
 end;
 
 procedure TCustomShellTreeView.SetRoot(const AValue: string);
+var
+  RootNode: TTreeNode;
 begin
   if FRoot=AValue then exit;
   FRoot:=AValue;
@@ -344,7 +346,16 @@
   if FRoot = '' then
     PopulateWithBaseFiles()
   else
-    PopulateTreeNodeWithFiles(nil, AValue);
+  begin
+    FRoot := ExpandFileName(FRoot);
+    //writeln('Adding ChildNode for ',froot);
+    RootNode := Items.AddChild(nil, AValue);
+    //writeln('GetPathFromNode(RootNode) = ',GetPathFromNode(RootNode));
+    RootNode.HasChildren := True;
+    //PopulateTreeNodeWithFiles(RootNode, AValue);
+    //writeln('RootNode.Count = ',RootNode.Count);
+    RootNode.Expand(False);
+  end;
   if Assigned(ShellListView) then
     ShellListView.Root := FRoot;
 end;
@@ -600,7 +611,6 @@
   Files := TStringList.Create;
   try
     GetFilesInDir(ANodePath, AllFilesMask, FObjectTypes, Files, FFileSortType);
-
     Result := Files.Count > 0;
 
     for i := 0 to Files.Count - 1 do
@@ -631,7 +641,6 @@
 begin
   // avoids crashes in the IDE by not populating during design
   if (csDesigning in ComponentState) then Exit;
-
   r := GetLogicalDriveStrings(SizeOf(Drives), Drives);
   if r = 0 then Exit;
   if r > SizeOf(Drives) then Exit;
@@ -681,14 +690,21 @@
   if ANode <> nil then  // Will return the root if nothing is selected (ANode=nil)
   begin
     // Build the path. In the future use ANode.Data instead of ANode.Text
-    Result := ANode.Text;
+    if (ANode.Parent = nil) and (GetRootPath <> '') then
+      Result := ''
+    else
+      Result := ANode.Text;
+    //writeln('GetPathFromNode: Initial Result=',Result);
     while (ANode.Parent <> nil) do
     begin
       ANode := ANode.Parent;
       Result := IncludeTrailingPathDelimiter(ANode.Text) + Result;
+      //writeln('GetPathFromNode: (Building) Result=',Result);
     end;
   end;
-  Result := GetRootPath() + Result;    // Include root directory
+  if not FilenameIsAbsolute(Result) then
+    Result := GetRootPath() + Result;    // Include root directory
+  //writeln('GetPathFromNode: Final Result=',Result);
 end;
 
 function TCustomShellTreeView.GetSelectedNodePath: string;
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to