XE4 TShellListView TShellTreeView 资源管理器

Delphi 2007 中没有 Shell 组件,但在Delphi的lib目录存在相关的源文件,并且在C:WindowsSystem32目录下存在vclshlctrls100.bpl的运行时包,唯独没有设计时包。

  但在Delphi的Demo中有一个ShellControls,安装其目录下的 dclshlctrls.dpk 即可成功安装Shell组件。

  注1:Shell组件安装后还是在组件面板的Sample页中;

  注2:Delphi2007的Demo目录在:我的电脑-共享文档-RAD Studio-Demos-DelphiWin32-VCLWin32;

  在 使用Shell这样的组件时,程序编译后都会出现以下的警告:[DCC Warning] Unit1.pas(7): W1005 Unit ‘ShellCtrls’ is specific to a platform ,如果您不想让他显示的话,可以在你工程相关源文件的开头加上以下代码:

  {$WARN UNIT_PLATFORM OFF}

XE4  XE5

D:UsersPublicDocumentsRAD Studio12.0SamplesDelphiVCLShellControlsvclshlctrls.dpk  

dclshlctrls.dpk

http://delphi.about.com/od/delphi-tips-2011/qt/xe2-vcl-shell-shellctrls.htm

ShellControls (TShellTreeView, TShellListView) In Delphi XE2

Using Shell Controls - Need My ShellCtrls.pas NOT Vcl.Shell.ShellCtrls.pas

By Zarko Gajic

Ads:

 Delphi XE2 Shell Controls

Ads

Delphi Globalization Toolwww.tsilang.comGlobalize your Delphi applications easy, professionally and fast!

义翘-圣诞好礼三重巨献www.sinobiological.cn北京义翘神州-蛋白/抗体生产专家 价格优惠,严格质控,现货储备

Delphi FireMonkey Controlswww.woll2woll.comProfessional FireMonkey Controls for Delphi (Grid, Editors, Lookups)

 
Ads

SDL Delphi Componentswww.lohninger.comHiTech components: 3D-plots, math, statistics, FFT, regression, meters

Image Library for Delphiwww.imageen.comCreate professional multimedia and photo apps with Delphi and ImageEn

Intro: 
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)DocumentsRAD Studio9.0SamplesDelphiVCLShellControls" folder. On Windows 7, the "$(ALLUSERSPROFILE)" is "C:UsersPublic". On Windows XP, the all users documents folder is "C:Documents and SettingsAll UsersDocuments".

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 ad studio9.0libWin32 elease" 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)DocumentsRAD Studio9.0SamplesDelphiVCLShellControls"

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:

  1. Add "$(ALLUSERSPROFILE)DocumentsRAD Studio9.0SamplesDelphiVCLShellControls" to the Library Path (Tools - Options - Environment Options - Delphi Options - Library list)
  2. Edit the uses class to specify the non unit-scoped name: delete "Vcl.Shell.ShellCtrls" and add "ShellCtrls"
Now, hit compile. This will work - your compiled version of "ShellCtrls.pas" from "$(ALLUSERSPROFILE)DocumentsRAD Studio9.0SamplesDelphiVCLShellControls" is used as the folder is now listed in the Library Path list.

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.

好的代码像粥一样,都是用时间熬出来的
原文地址:https://www.cnblogs.com/jijm123/p/14379251.html