Glyph TShellTreeView Component

Description

The ShellTreeView component is a window, which displays a hierarchical tree view of the system’s shell folders. Every entry shows the icon and the name of the folder. By double clicking an entry, the user can show or hide a list of the subfolders of the selected folder. Alternatively, the user can click the [+] or [-] buttons in front of an entry.

To show the button of the root of the hierarchy, set the ShowRoot property to True.

If the user clicks an entry with the right mouse button, the context menu of the selected folder pops up. The contents of the menu are folder dependent and system defined.

You can set the root folder of the tree view with the RootFolder property. The directory of the selected folder is in the Directory property and the attributes in the FolderAttributes property. To automatically display the directory in an associated Label, set the DirLabel property.

TShellTreeView is a rather exact copy of the left pane of the Windows Explorer.

TShellTreeView is a descendant of TCustomTreeView and contains, additionally to the properties already mentioned, also most properties, methods and events of this component. The properties and methods which were not published, like Images, Items, ShowLines, ShowButtons or Sorted, are either inappropriate or shouldn’t be changed directly.

Properties

Additionally to the properties all components have, TShellTreeView has the following new or overridden properties:

Directory property

Contains the currently selected directory.

property Directory: string;

The property contains the selected directory for the ShellTreeView component. If the selected folder is not a file system folder (e.g. My Computer or Control Panel), the string is empty. The FolderAttributes property contains the shell attributes for this folder.

DirLabel property

Contains the Label that shows the current directory.

property DirLabel: TLabel;

This property makes it easy to fill a Label component with the directory of the currently selected folder. If the selected folder changes, the Caption of the Label is changed accordingly.

FolderAttributes property

Contains the attributes for the currently selected folder.

property FolderAttributes: TFolderAttributes;

The property FolderAttributes is read only. It contains representations of the shell attributes of the selected folder in the tree view. These attributes should not be confused with the file attributes of a folder.

The TFolderAttribute enumeration type describes the possible attributes a shell folder can have.

type
  TFolderAttribute = (faCanCopy, faCanDelete, faCanLink, faCanMove, faCanRename,
    faDropTarget, faHasPropSheet, faGhosted, faLink, faReadOnly, faShare,
    faHasSubFolder, faFileSystem, faFileSysAncestor, faFolder, faRemovable,
    faValidate);
  TFolderAttributes = set of TFolderAttribute;

The following table shows the possible values and their meanings.

Value Description
faCanCopy Folder can be copied
faCanDelete Folder can be deleted
faCanLink It is possible to create a shortcut for the folder
faCanMove Folder can be moved
faCanRename Folder can be renamed
faDropTarget Folder can be a drop target
faHasPropSheet Folder has a property sheet
faGhosted Folder should be displayed with a “ghosted” icon
faLink Folder is a shortcut
faReadOnly Folder is read-only
faShare Folder is shared with other applications
faHasSubFolder Folder has subfolders (and is therefore expandable in the left pane of the Explorer)
faFileSystem Folder is part of the file system
faFilesysAncestor Folder contains file system folders
faFolder Folder is a folder (defined for future use)
faRemovable Folder is a removable media
faValidate Validate cached information

RootFolder property

Contains the root folder for the tree.

property RootFolder: TRootFolder default rfDesktop;

This enables you to set the root folder of the tree view to a folder other than the Desktop folder. This can be one of the predefined Shell folders. The default value is rfDesktop for the Desktop folder.

type
  TRootFolder = (rfDesktop, rfPrograms, rfControls, rfPrinters, rfPersonal,
    rfFavorites, rfStartUp, rfRecent, rfSendTo, rfBitBucket, rfStartMenu,
    rfDesktopDirectory, rfDrives, rfNetwork, rfNethood, rfFonts, rfTemplates);

TRootFolder can have the following values:

Value Description
rfDesktop Desktop
rfPrograms Program files
rfControls System Control
rfPrinters Printer
rfPersonal Personal
rfFavorites Favorites
rfStartUp Autostart
rfRecent Recent Documents
rfSendTo SendTo (for Send to)
rfBitBucket Recycle bin
rfStartMenu Start menu
rfDesktopDirectory Desktop directory
rfDrives My Computer
rfNetwork Network
rfNethood Network Neighborhood
rfFonts Fonts
rfTemplates New file templates

ShowRoot property

Enables showing the root as a node.

property ShowRoot: Boolean;

The ShowRoot property specifies whether lines connecting root (top-level) items are displayed. To show lines connecting root items, set the tree view’s ShowRoot and ShowLines properties to True.

Standard Disclaimer for External Links

These links are being provided as a convenience and for informational purposes only; they do not constitute an endorsement or an approval of any of the products, services or opinions of the corporation or organization or individual. I bear no responsibility for the accuracy, legality or content of the external site or for that of subsequent links. Contact the external site for answers to questions regarding its content.

Disclaimer and Copyright

The coding examples presented here are for illustration purposes only. The author takes no responsibility for end-user use. All content herein is copyrighted by Rudy Velthuis, and may not be reproduced in any form without the author's permission. Source code written by Rudy Velthuis presented as download is subject to the license in the files.

Valid HTML5! Valid CSS!