Forum > Packages and Libraries
[Solved] TShellTreeView
(1/1)
jcmontherock:
I'm using TShellTreeView under Windows for selecting and working with some files and/or directories. When an entry has been selected I will get the path of this entry. I use for that: "ShellTreeView.items[n].GetTextPath". The result is not correct because the path delim char is '/' instead '\'. The path itself is ok.
Is it a bug or is it normal ?
wp:
The recommended way to get the full path to a shelltree node is ShellTreeView.GetPathFromNode(ANode). GetTextPath is the method inherited from TCustomTreeView, and the items joined by this path not necessarily are elements of the file system. Imagine the hierarchy of classes in the LCL: then GetTextPath would return for TEdit: 'TObject/TPersistent/TComponent/TLCLComponent/TControl/TWinControl/TCustomEdit/TEdit' where '/' is some kind of path delimiter. In fact, in Laz main TCustomTreeView has a (protected) property PathDelimiter which is published in the new TShellTreeView to match the SysUtils.PathDelim, i.e. you can use GetTextPath and GetPathFromNode in the same way.
dsiders:
--- Quote from: jcmontherock on May 21, 2023, 06:12:11 pm ---I'm using TShellTreeView under Windows for selecting and working with some files and/or directories. When an entry has been selected I will get the path of this entry. I use for that: "ShellTreeView.items[n].GetTextPath". The result is not correct because the path delim char is '/' instead '\'. The path itself is ok.
Is it a bug or is it normal ?
--- End quote ---
I do not see that behavior using 2.3.0 (trunk). What version are you using?
wp:
--- Quote from: dsiders on May 21, 2023, 07:59:00 pm ---I do not see that behavior using 2.3.0 (trunk). What version are you using?
--- End quote ---
This is because in trunk the TCustomShellTreeView has a protected property PathDelimiter which is set in the TShellTreeView to the PathDelimiter of the file system.
jcmontherock:
Solved thanks a lot.
I replace:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sPath := ShellTreeView.items[i].GetTextPath;sPath := sPath.Replace('/', '\', [rfReplaceAll, rfIgnoreCase]);by:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sPath := ShellTreeView.GetPathFromNode(ShellTreeView.items[i]);
and it's work....
Navigation
[0] Message Index