View Issue Details

IDProjectCategoryView StatusLast Update
0022538LazarusLCLpublic2012-08-10 20:52
ReporteroceanAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0022538: ShellTreeView property path is missing
DescriptionIn Delphi there is path, you can do for example

ShellTreeView1.path:='C:/Windows/';

or

s:=ShellTreeView1.path;
TagsNo tags attached.
Fixed in Revisionr38181, r38221, r38224
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • stv.patch (703 bytes)
    Index: lcl/shellctrls.pas
    ===================================================================
    --- lcl/shellctrls.pas	(revision 38209)
    +++ lcl/shellctrls.pas	(working copy)
    @@ -581,7 +581,7 @@
     begin
       if FRoot <> '' then Result := FRoot
       else Result := GetBasePath();
    -  Result := IncludeTrailingPathDelimiter(Result);
    +  if Result <> '' then Result := IncludeTrailingPathDelimiter(Result);
     end;
     
     { Returns true if at least one item was added, false otherwise }
    @@ -702,7 +702,7 @@
     
     function TCustomShellTreeView.GetPath: string;
     begin
    -  Result := GetPathFromNode(Selected, False);
    +  Result := GetPathFromNode(Selected);
     end;
     
     procedure TCustomShellTreeView.SetPath(AValue: string);
    
    stv.patch (703 bytes)

Relationships

related to 0022603 closedBart Broersma Createrelativepath doesn't work 

Activities

Juha Manninen

2012-07-31 23:38

developer   ~0061336

Does Path have the same meaning as Root in LCL's ShellTreeView?
We could add Path as a synonym for Root.

ocean

2012-08-01 08:30

reporter   ~0061341

s:=ShellTreeview1.Path; is similar to s:=ShellTreeview1.GetSelectedNodePath;

But the other way there is problem, because there is nothing like SetSelectedNodePath?

In Delphi I'm saving last used path, and next time expand tree by ShellTreeview1.Path:=MySavedPath; (if possible)

theo

2012-08-01 13:20

reporter   ~0061342

Do you mean sth. like this (hack):
http://www.lazarusforum.de/viewtopic.php?p=33182#p33182

ocean

2012-08-02 11:14

reporter   ~0061352

Yes, that's what I mean

Juha Manninen

2012-08-05 11:33

developer   ~0061430

theo, can you please explain what happens here:

{$IFDEF windows}
  Str[0] := Str[0] + PathDelim;
{$ENDIF}

Why is it needed?

theo

2012-08-05 13:22

reporter   ~0061431

@Juha: This code is old. Maybe sth. changed in ShellTreeView. I think it's no longer necessary. (First node was probably C:\ before and is C: now)

Btw. now Str.StrictDelimiter:=True is needed.

Juha Manninen

2012-08-05 14:22

developer   ~0061432

I implemented it in r38174.
Could you please test it on Windows and other platforms. I tested only on Linux.
I will mark this issue as resolved only after it is tested some more.

theo, I followed your idea in the code although I modified it a lot. Thanks.
I also modified GetPathFromNode() and added an assertion. Testing should be done with assertions enabled (-Sa).

BTW, "ANode := STV.TopItem;"
is wrong. It returns the node at the top of the client window, not the tree's absolute first node.

theo

2012-08-05 19:50

reporter   ~0061440

@Juha: Does it work for you on Linux?

I think there is something missing after
sl.DelimitedText := TrimFilename(AValue);
like:
if Sl[0] = '' Then Sl[0] := PathDelim; //Sl[0] should not be empty.

Juha Manninen

2012-08-06 21:54

developer   ~0061452

Yes, sorry. It didn't work even on Linux when the root was empty. I fixed it in r38181.
Please test again on Windows.

theo

2012-08-06 23:21

reporter   ~0061454

I made a test under wine, and it does not work.
It does not even expand anymore when clicking on the arrow on C: oder D: etc.
Problem is somewhere in GetPathFromNode with AIncludeRoot.
This returns something like
\C:
so not working. I don't know exactly what your idea was with AIncludeRoot.

Juha Manninen

2012-08-07 20:00

developer   ~0061488

AIncludeRoot is used to leave out the root dir when getting the Path.
How should it work? I did not find ShellTreeView at all in Delphi XE2.

Now my Lazarus is not working on Windows any more. It halts for example when creating a new project.
Could you please fix this issue and send a patch. I will apply it.

theo

2012-08-07 21:07

reporter   ~0061491

> How should it work? I did not find ShellTreeView at all in Delphi XE2.

I don't know. I don't have a recent Delphi and I'm not really interested in Windows anymore.
Maybe user ocean can tell us.
I've only tested under wine, but the debugger doesn't work there.

Felipe Monteiro de Carvalho

2012-08-08 08:22

developer   ~0061499

If the fixes don't work, I think they should be reverted until a proper one is found.

ocean

2012-08-08 08:48

reporter   ~0061502

Original code worked, when I removed ifdef. What exactly prevents developers testing Windows, Win8 preview is free to download for example

DelphiXE2 does have shelltreeview, but shellcontrols are not installed by default. It's in samples folder as always

I'll try to look why it doesn't work.

ocean

2012-08-08 10:41

reporter   ~0061506

Result := IncludeTrailingPathDelimiter(Result);

I would suggest

if Result <> '' then Result := IncludeTrailingPathDelimiter(Result);

theo

2012-08-08 12:07

reporter   ~0061512

Thanks ocean. Can you test your solution with and without values in property 'Root'?
Once it works, please create a patch which Juha can apply.
http://wiki.freepascal.org/Creating_A_Patch

ocean

2012-08-08 14:04

reporter   ~0061517

Without root, it works after my little change (previous post)

With root set C:\ there is problem with line:

if DirectoryExistsUTF8(AValue) then
    AValue := CreateRelativePath(AValue, GetRootPath());

Function CreateRelativePath doesn't work, it returns same string.

I would suggest:

if DirectoryExistsUTF8(AValue) then
     Avalue:=Stringreplace(AValue, GetRootPath(), '', []);

Now it works with and without root.

showmessage(shelltreeview1.path); shows relative path. This is wrong, it should always show full path. Like I wrote in post1, correct is GetSelectedNodePath;

Hope this helps!

theo

2012-08-08 17:22

reporter   ~0061524

> Hope this helps!

Please create a patch for Juha.
http://wiki.freepascal.org/Creating_A_Patch

2012-08-09 10:18

 

stv.patch (703 bytes)
Index: lcl/shellctrls.pas
===================================================================
--- lcl/shellctrls.pas	(revision 38209)
+++ lcl/shellctrls.pas	(working copy)
@@ -581,7 +581,7 @@
 begin
   if FRoot <> '' then Result := FRoot
   else Result := GetBasePath();
-  Result := IncludeTrailingPathDelimiter(Result);
+  if Result <> '' then Result := IncludeTrailingPathDelimiter(Result);
 end;
 
 { Returns true if at least one item was added, false otherwise }
@@ -702,7 +702,7 @@
 
 function TCustomShellTreeView.GetPath: string;
 begin
-  Result := GetPathFromNode(Selected, False);
+  Result := GetPathFromNode(Selected);
 end;
 
 procedure TCustomShellTreeView.SetPath(AValue: string);
stv.patch (703 bytes)

ocean

2012-08-09 10:19

reporter   ~0061531

Attached, if I got it right?!

I didn't do that stringreplace yet, depends what happens to createrelativepath bug 22603

But I can add new patch, if you like stringreplace too.

Juha Manninen

2012-08-10 02:04

developer   ~0061543

Thanks. I tweaked the code some more and applied in r38221. Please test again.
I included the StringReplace call, too.

And sorry for the slow response and poor testing on Windows. The only reason is that I don't have as much time and energy for this task as I did some time ago, due to my work mainly. Something is broken in my Windows and I just don't have the motivation to tweak with it. I am happy there are clever testers / committers.

Patches are welcome for other issues, too. New open issues seem to pile up.
Many people report bugs but only few people fix them and send patches.

ocean

2012-08-10 10:27

reporter   ~0061548

Unfortunately your tweak doesn't work, when root is empty.

if FRoot = '' then AValue := IncludeLeadingPathDelimiter(AValue)

Avalue becomes \C:\

And exits here

if not DirectoryExistsUTF8(GetRootPath()+AValue) then Exit;

Juha Manninen

2012-08-10 20:15

developer   ~0061563

Yes, sorry for the hassle. I fixed it and even tested on Windows.
I believe it works now. Please test.

ocean

2012-08-10 20:52

reporter   ~0061564

Works now, thanks!

Issue History

Date Modified Username Field Change
2012-07-31 11:00 ocean New Issue
2012-07-31 11:00 ocean Widgetset => Win32/Win64
2012-07-31 23:38 Juha Manninen Note Added: 0061336
2012-08-01 00:05 Juha Manninen LazTarget => -
2012-08-01 00:05 Juha Manninen Status new => feedback
2012-08-01 08:30 ocean Note Added: 0061341
2012-08-01 13:20 theo Note Added: 0061342
2012-08-02 11:14 ocean Note Added: 0061352
2012-08-04 15:01 Juha Manninen Status feedback => assigned
2012-08-04 15:01 Juha Manninen Assigned To => Juha Manninen
2012-08-05 11:33 Juha Manninen Note Added: 0061430
2012-08-05 13:22 theo Note Added: 0061431
2012-08-05 14:22 Juha Manninen Note Added: 0061432
2012-08-05 14:22 Juha Manninen Status assigned => feedback
2012-08-05 19:50 theo Note Added: 0061440
2012-08-06 21:54 Juha Manninen Note Added: 0061452
2012-08-06 23:21 theo Note Added: 0061454
2012-08-07 20:00 Juha Manninen Note Added: 0061488
2012-08-07 21:07 theo Note Added: 0061491
2012-08-08 08:22 Felipe Monteiro de Carvalho Note Added: 0061499
2012-08-08 08:48 ocean Note Added: 0061502
2012-08-08 10:41 ocean Note Added: 0061506
2012-08-08 12:07 theo Note Added: 0061512
2012-08-08 14:04 ocean Note Added: 0061517
2012-08-08 17:22 theo Note Added: 0061524
2012-08-09 10:18 ocean File Added: stv.patch
2012-08-09 10:19 ocean Note Added: 0061531
2012-08-09 21:11 Juha Manninen Relationship added related to 0022603
2012-08-10 02:04 Juha Manninen Note Added: 0061543
2012-08-10 10:27 ocean Note Added: 0061548
2012-08-10 20:15 Juha Manninen Fixed in Revision => r38181, r38221, r38224
2012-08-10 20:15 Juha Manninen Status feedback => resolved
2012-08-10 20:15 Juha Manninen Resolution open => fixed
2012-08-10 20:15 Juha Manninen Note Added: 0061563
2012-08-10 20:52 ocean Status resolved => closed
2012-08-10 20:52 ocean Note Added: 0061564