如何在“浏览文件夹”中使用自定义图标对话?
NetBeans IDE 中的“打开项目...”对话框(见下图)中有一个很好的功能,它根据该文件夹中的项目类型使用文件夹符号的自定义图标。
例如,如果文件夹包含 pom.xml 文件,则会显示 Maven 项目符号。
也许 Windows 标准对话框或 shell 视图控件中还有一个扩展点,可用于覆盖默认文件夹图标。
到目前为止,我所知道的所有解决方案都需要进行系统范围的更改,但是是否还有一种无需系统修改且仅适用于当前应用程序的解决方案?
更新:您建议使用哪个 VCL 组件作为自定义对话框的起点,我可以使用 TShellTreeView 或 TcxShellTreeView 吗?
There is a nice feature in the "Open Project..." dialog (see image below) in the NetBeans IDE which uses a custom icon for the folder symbols depending on the project type in that folder.
For example, if a folder contains a pom.xml file, the Maven project symbol appears.
Maybe there also an extension point in the Windows standard dialog or a shell view control which can be used to override the default folder icon.
All solutions I know so far need a system-wide change, but is there also a solution which works without system modifications and only for the current application?
Update: which VCL component would you suggest as a starting point for a custom dialog, could I use TShellTreeView or TcxShellTreeView?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
继承自“TCustomTreeView”,
TShellTreeView
支持开箱即用的图像。可以将ImageList
分配给其Images
属性,并在其OnGetImageIndex
事件中,可以指定列表中对应节点的图像索引。提供。这样做的缺点是,所有节点都必须使用图像列表中的图像,即系统图像列表中不会有图像。下面的示例演示了如何为未自定义的节点检索系统映像。它对个人文件夹中的“RAD Studio”文件夹使用自定义映像,并对所有其他节点使用系统映像。
ImageList1
保存我们的自定义图像,ImageList2
是分配给“ShellTreeView”的“Images”属性的图像。正如代码中所注释的,这不应该被视为工作设计;可以采用某种匹配“图像索引”和“系统图像列表索引”的查找,而不是具有大量未使用图像的图像列表。
Descending from 'TCustomTreeView',
TShellTreeView
has support for images out of the box. AnImageList
can be assigned to itsImages
property, and in itsOnGetImageIndex
event the index of the image in the list for the corresponding node can be supplied.A downside of that is, all nodes will have to use the images in the imagelist, that is there won't be images from the system image list. The below example demonstrates how system images can be retrieved for nodes which won't be customized. It uses a custom image for 'RAD Studio' folder in the personal folder and uses system images for all other nodes.
ImageList1
holds our custom images,ImageList2
is the one that is assigned to the 'Images' property of the 'ShellTreeView'.As commented in the code, this should not be taken for a working design; Instead of an imagelist having lots of unused images, some kind of a lookup that matches 'image index' and 'system image list index' could be employed.
IShellIconOverlay 和 IShellIconOverlayIdentifier 接口用于构建覆盖图标 shell 扩展,这些扩展是系统范围的,而不是针对每个应用程序的,在 delphi 中,这两个接口都存在于 ShlObj 单元中。
检查此链接的示例
更新
我认为 Netbeans IDE 对话框在您的问题中发布,使用自定义图标和标准控件绘制自己的对话框。您可以使用标准 vcl 控件构建自己的对话框以获得相同的效果。
The IShellIconOverlay and the IShellIconOverlayIdentifier Interfaces are used to build overlay icons shell extensions , theses extensions are system wide not per application, in delphi both interfaces exists in the ShlObj unit.
check this link for an example
UPDATE
i think wich the Netbeans IDE dialog posted in your question, draw their own dialog box using custom icons and standard controls. you can gain the same effect building your own dialog box using the standard vcl controls.