Recent

Author Topic: [SOLVED]TShellTreeView - how to rename a folder  (Read 5640 times)

wp

  • Hero Member
  • *****
  • Posts: 13264
Re: [SOLVED]TShellTreeView - how to rename a folder
« Reply #15 on: February 03, 2022, 11:45:46 pm »
Looking at it again, I think the "real" issue is that we have double storage of the file name in TShellTreeNode: first in the Text property of the node, second in the FileInfo.Name (FileInfo is the SearchRec obtained by FindFirst/FindNext). That's always a source of trouble...

Since the FileInfo is not directly accessible by user, only by methods ShortFileName and LongFileName, we could simply ignore the FileInfo.Name and use the Node.Text for construction of the short and long filenames:

Code: Pascal  [Select][+][-]
  1. function TShellTreeNode.ShortFilename: String;
  2. begin
  3.   Result := Text;
  4. end;
  5.  
  6. function TShellTreeNode.FullFilename: String;
  7. begin
  8.   if (FBasePath <> '') then
  9.     Result := AppendPathDelim(FBasePath) + Text
  10.   else
  11.     //root nodes
  12.     Result := Text;
  13.   {$if defined(windows) and not defined(wince)}
  14.   if (Length(Result) = 2) and (Result[2] = DriveSeparator) then
  15.     Result := Result + PathDelim;
  16.   {$endif}
  17. end;

After having done these changes in unit ShellCtrls, GetMem's sample project runs without crashing.

balazsszekely

  • Guest
Re: [SOLVED]TShellTreeView - how to rename a folder
« Reply #16 on: February 04, 2022, 08:14:27 am »
@wp

I can confirm that the above changes works fine.

wp

  • Hero Member
  • *****
  • Posts: 13264
Re: [SOLVED]TShellTreeView - how to rename a folder
« Reply #17 on: February 04, 2022, 10:55:41 am »
Committed it to Laz/main and requested backporting to fixes.

Wrote a bugreport to document the reason why it is done (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39629).

[EDIT]
I also checked whether the very similar TShellListView has the same issue with renaming - no, it has not, it is working correctly out of the box.
« Last Edit: February 05, 2022, 11:23:54 am by wp »

balazsszekely

  • Guest
Re: [SOLVED]TShellTreeView - how to rename a folder
« Reply #18 on: February 05, 2022, 09:12:22 pm »
Committed it to Laz/main and requested backporting to fixes.

Wrote a bugreport to document the reason why it is done (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39629).

[EDIT]
I also checked whether the very similar TShellListView has the same issue with renaming - no, it has not, it is working correctly out of the box.

Thanks wp!

 

TinyPortal © 2005-2018