Recent

Author Topic: How can I make a file explorer using VirtualTreeView?  (Read 397 times)

Froxter

  • New Member
  • *
  • Posts: 13
How can I make a file explorer using VirtualTreeView?
« on: April 26, 2025, 10:35:11 am »
Someone recommended me to install this package and I don't know very well how to use it to create my explorer, but in case it can't be done then how can I do it using a TreeView and a FileListBox?

maurog

  • New Member
  • *
  • Posts: 44
Re: How can I make a file explorer using VirtualTreeView?
« Reply #1 on: April 26, 2025, 11:05:00 am »
"Is there a specific reason why you are not using ShellTreeView and ShellListView? I believe with these components you'd have less effort. Here's even a small example:"

https://lazplanet.blogspot.com/2013/06/create-simple-file-browser-in-2-minutes.html

Regards
Maurog.
And yes, Lazarus is definitely a beast – it comes with everything you need, but sometimes also more than you expect. 😅 (Chat-GPT)

Ally

  • Jr. Member
  • **
  • Posts: 69
Re: How can I make a file explorer using VirtualTreeView?
« Reply #2 on: April 26, 2025, 11:13:31 am »
Hello Froxter,

at https://forum.lazarus.freepascal.org/index.php/topic,70909.msg553094.html#msg553094 you can find an example that shows how it works with ShellTreeView and ShellListView.

Greetings
Roland

Froxter

  • New Member
  • *
  • Posts: 13
Re: How can I make a file explorer using VirtualTreeView?
« Reply #3 on: April 26, 2025, 11:19:34 am »
Hello Froxter,

at https://forum.lazarus.freepascal.org/index.php/topic,70909.msg553094.html#msg553094 you can find an example that shows how it works with ShellTreeView and ShellListView.

Greetings
Roland
I understand that i can make it easy with these components and i did it before! but im changing it because that creashed my programs when i run them in windows XP and i really need my programs run in that OS

wp

  • Hero Member
  • *****
  • Posts: 12800
Re: How can I make a file explorer using VirtualTreeView?
« Reply #4 on: April 26, 2025, 11:19:52 am »
I agree with maurog and Ally that the combination of ShellTreeView and ShellListView is very easy to use.

If you insist on VirtualTreeView you should know that usually there is no need to install anything for it because it is bundled with Lazarus (package "laz.virtualtreeview", palette "LazControls"). An explorer-like sample project can be found in unit DrawTreeDemo of the vst_advanced project (in folder "examples/virtualtreeview" of the Lazarus installation). Somewhere in the forum, there is also code for an elemental worked-out file explorer, but I did not find it any more.

wp

  • Hero Member
  • *****
  • Posts: 12800
Re: How can I make a file explorer using VirtualTreeView?
« Reply #5 on: April 26, 2025, 11:23:44 am »
I understand that i can make it easy with these components and i did it before! but im changing it because that creashed my programs when i run them in windows XP and i really need my programs run in that OS
You should report this. I don't see a reason why the ShellCtrls should not work in Win XP.

Froxter

  • New Member
  • *
  • Posts: 13
Re: How can I make a file explorer using VirtualTreeView?
« Reply #6 on: April 26, 2025, 11:25:34 am »
I understand that i can make it easy with these components and i did it before! but im changing it because that creashed my programs when i run them in windows XP and i really need my programs run in that OS
You should report this. I don't see a reason why the ShellCtrls should not work in Win XP.
in XP when i add a ShellTreeView in my form i get a crash of access violation. Im using lazarus 3.8

wp

  • Hero Member
  • *****
  • Posts: 12800
Re: How can I make a file explorer using VirtualTreeView?
« Reply #7 on: April 26, 2025, 11:49:57 am »
Just saw in yesterday's commit notes of Lazarus/main: "Win32, LCL: fix crash of TWin32WSCustomShellTreeView on Win-XP." I checked it in a VM with Win XP and it removes the crash.

You can apply this change easily to your own version:
  • Make a backup copy of file lcl/interfaces/win32/win32wsshellctrls.pas (just in case something goes very wrong...)
  • Load this file into the IDE, find the implementation of class function TWin32WSCustomShellTreeView.GetBuiltinIconSize
  • Between the lines "ico := ..." and "try" add the following highlighted block:
Code: Pascal  [Select][+][-]
  1.     ...
  2.     ico := GetShellIcon(WideString('C:'));
  3.     if ico = nil then
  4.     begin
  5.       Result := Types.Size(0, 0);
  6.       exit;
  7.     end;
  8.     try
  9.     ...
  • Rebuild the IDE ("Tools" > "Build Lazarus")

Froxter

  • New Member
  • *
  • Posts: 13
Re: How can I make a file explorer using VirtualTreeView?
« Reply #8 on: April 26, 2025, 01:31:46 pm »
Just saw in yesterday's commit notes of Lazarus/main: "Win32, LCL: fix crash of TWin32WSCustomShellTreeView on Win-XP." I checked it in a VM with Win XP and it removes the crash.

You can apply this change easily to your own version:
  • Make a backup copy of file lcl/interfaces/win32/win32wsshellctrls.pas (just in case something goes very wrong...)
  • Load this file into the IDE, find the implementation of class function TWin32WSCustomShellTreeView.GetBuiltinIconSize
  • Between the lines "ico := ..." and "try" add the following highlighted block:
Code: Pascal  [Select][+][-]
  1.     ...
  2.     ico := GetShellIcon(WideString('C:'));
  3.     if ico = nil then
  4.     begin
  5.       Result := Types.Size(0, 0);
  6.       exit;
  7.     end;
  8.     try
  9.     ...
  • Rebuild the IDE ("Tools" > "Build Lazarus")

OMG IT WORKS PERFECTLY!! YTSM :,D

 

TinyPortal © 2005-2018