TShellTreeView Node name vs node path lazarus / 21-General ---------------------------------------------------------------------- Redenegue · 2024-03-12 18:07 In my tree I want to see the drives name, like in Windows explorer. I have written code to implement this, but its more like a hack than a real solution. Also, my code drops the drive icon, which cannot be restored due to lack of an Image List. The real solution as I see it, is to intercept the node text and alter the drive path before Lazarus processes it. For example: node text = C:\Boot Drive    ->    C:\ Doing this, Lazarus will ignore the text and and only use the drive path. What I need, is the location of the Lazarus code, where it extracts the path, so I can alter it before Lazarus continues its process. I have searched for hours and can not find it. Also, it would be nice if Lazarus was altered for all users to do this. It should only require a few lines of code, and an added option to use it. For myself I never use anything but the system root, so the option is not necessary for me. ---------------------------------------------------------------------- wp · 2024-03-12 18:59 You mean, where the tree is populated? This happens in TCustomShellTreeView.PopulateTreeNodeWithFiles of file shellctrls.pas in the lcl directory of your Lazarus installation. (Simply CTRL+click on the word TShellTreeView in your source, and the IDE will open the unit where it is implemented). But I am not sure if manipulating the displayed node text won't break the component at some place. I know that every node contains a TFileItem in its Data field (with the physical path specification and additional data), but it could be that some tasks are done based on the node text itself instead of the path in TFileItem. ---------------------------------------------------------------------- Redenegue · 2024-03-13 02:57 Thank you. I should have looked at "populate". Since nothing appears to be affected by a "wrong" directory name as text, I do not expect that forcing it to be correct will hurt anything. If I can make the necessary changes, I will reply. ---------------------------------------------------------------------- Redenegue · 2024-03-13 04:12 It works great! This is what I added:     If Result[2] = ':' then     begin          Result := Copy(Result,1,2) + '\';     end; This is all I need, but it does depend on using the correct name format including the ':'. With a few more lines, it should be fine for others. The icons finally appear just like in Windows Explorer. It also expands correctly. I populate my own TListView, so I have not and will not test it with either TListView or TShellListView. TShellListView had too many issues for me to use. Again, thank you for pointing to the code. ---------------------------------------------------------------------- Redenegue · 2024-03-13 15:45 I made a little mistake, corrected here. I forgot about the expanded paths. The test has to be on the node text not the path. If ANode.Text[2] = ':' then Result := Copy(Result,1,2) + '\'; ---------------------------------------------------------------------- wp · 2024-03-13 15:54 I don't understand... My D: drive is named "Data", and Windows displays it as "Data (D:)". I thought you wanted to show the drives like this. But the "C:\" or "D:\" that you generate is already there (except for the backslash)... ---------------------------------------------------------------------- Redenegue · 2024-03-18 11:58 I wanted to display my drives names like this: C: Boot Drive But when I changed it, the windows icons would not appear. It also interfered with the paths. By changing it inside Lazarus, it fixed all but one issue. For me its not important, but I can not programically change the TShellTreeView path. I have looked for a fix, but lacking the ability to trace the working program, it has been difficult. I installed a bunch of code to debug it, and at the moment I think it might be involving the FRoot variable. When Lazarus finds the c drive, it thinks the path is C:\Boot Drive, but it is really just C:\. That is what I fixed. Somewhere, Lazarus is still finding the C:\Boot Drive path before changing the path. That is what I am looking for now. So, you were correct about the alteration affecting something else. I think this fix will be easy also when I find the source of the problem.