unit DirectoryTree;
interface
uses
SysUtils, Classes, Controls, ComCtrls, Graphics, Windows, ShellApi;
type
TDirectoryTree =
class(TCustomTreeView)
private
imgList: TImageList;
protected
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
published
property Align;
...
end;
procedure Register;
implementation
const
NAME_DESKTOP = '
C:\';
ICON_DESKTOP = 0;
function GetShellDescription(
const Name:
String):
String;
...
end;
function GetShellIcon(
const Name:
String;
const Open: Boolean = False): TIcon;
...
end;
procedure Register;
begin
RegisterComponents('
Sim', [TDirectoryTree]);
end;
constructor TDirectoryTree.Create(AOwner: TComponent);
var tmpNode: TTreeNode;
begin
//Try
inherited Create(AOwner);
imgList := TImageList.Create(AOwner);
imgList.Masked := False;
imgList.BkColor := Color;
imgList.AddIcon(GetShellIcon(NAME_DESKTOP));
Images := imgList;
tmpNode := Items.Add(
nil, GetShellDescription(NAME_DESKTOP));
tmpNode.ImageIndex := ICON_DESKTOP;
tmpNode.SelectedIndex := ICON_DESKTOP;
tmpNode.StateIndex := -1;
//Except
//End;
end;
destructor TDirectoryTree.Destroy;
begin
//Images := nil;
//imgList.Free;
inherited Destroy;
end;
end.