Delphi XE2 has Vcl.Shell.ShellCtrls.pas, but the Shell Controls package is not installed by default. There's ShellCtrls.pas in the samples folder (as before) - use it to manually install the package.
Trick question: what compiled (DCU) version of "shellctrls.pas" is used by Delphi?
I have an application which extensively uses controls from the "Shell Control Property and Component Editors" package. The package is shipped with Delphi as a sample project for quite some time. The shell components included are TShellTreeView, TShellListView, TShellComboBox and TShellChangeNotifier.
The TShellListView control can be used to display files from the file system. Paired with TShellTreeView shell, the TShellListView can be used to mimic Windows Explorer user interface.
In Delphi XE2, the package is not installed by default and you have to install it manually. The source files are located inside the "$(ALLUSERSPROFILE)\Documents\RAD Studio\9.0\Samples\Delphi\VCL\ShellControls" folder. On Windows 7, the "$(ALLUSERSPROFILE)" is "C:\Users\Public". On Windows XP, the all users documents folder is "C:\Documents and Settings\All Users\Documents".
Once you have the packages installed, the "Samples" section on the Tool Palette will host the mentioned 4 components.
My Own Version Of TSHellListView
By design, the TShellListView sorts files (and folders) ascending by their name. There's no "OnCompare" event you can handle to change the sort order or the column (name, type, date modified, size) used for sorting.The Add Custom Sorting To Delphi's TShellListView Control explains how to do a little tweak to the source unit (ShellCtrls.pas) where TShellList view is implemented, recompile the package and use the tweaked version of the TShellListView (exposing one more property).
No Go In Delphi XE2
Once you are done with recompiling of the Shell Controls package, start a new VCL Forms application in Delphi XE2, drop TShellListView on the form and try accessing the added FolderList property ... no go! :(Note the uses clause of your unit: it will list "Vcl.Shell.ShellCtrls".
Delphi XE2 introduced Unit Scope Names - prefixes that are prepended to unit names in the VCL (, FMX, RTL) libraries.
When you hit Compile, Delphi looks for compiled units your code uses into the Library Path (Tools - Options - Environment Options - Delphi Options - Library) list. This list has "c:\program files (x86)\embarcadero\rad studio\9.0\lib\Win32\release" as the first item - go there and locate the "Vcl.Shell.ShellCtrls.dcu" used by Delphi to compile your application.
This is NOT the "ShellCtrls.dcu" I want to be used. My version of "ShellCtrls.pas" is located, remember, here: "$(ALLUSERSPROFILE)\Documents\RAD Studio\9.0\Samples\Delphi\VCL\ShellControls"
How do I tell Delphi to use my version of the ShellCtrls unit and not the one shipped with Delphi XE2 (but not installed on the Tool Palette) ?
Two actions were required:
- Add "$(ALLUSERSPROFILE)\Documents\RAD Studio\9.0\Samples\Delphi\VCL\ShellControls" to the Library Path (Tools - Options - Environment Options - Delphi Options - Library list)
- Edit the uses class to specify the non unit-scoped name: delete "Vcl.Shell.ShellCtrls" and add "ShellCtrls"
Epilogue
Confession: maybe there's a better way to do the above. Maybe with some next Update, shell controls will be installed by default. Maybe I done something wrong :)After all, the above work was done while I was upgrading one of my bigger application to Delphi XE2 (new machine, full backup, and all that work).
All in all, I have my version of TShellListView and my sorting works. I am able to compile the entire project (quite a few third-party components used). Am happy, can move on adding more planned features to the application.
Moved from Delphi XE to Delphi XE2 and I have to say I am not unhappy with the time invested in the upgrade. If you can, go for XE2.