| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ShellCtrls, StdCtrls, ExtCtrls, CommCtrl;
type TForm1 = class(TForm) Image1: TImage; Button1: TButton; ShellTreeView1: TShellTreeView; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var IList: HIMAGELIST; W, H: Integer; Item: TTVItem; begin with ShellTreeView1 do begin IList := TreeView_GetImageList(Handle, TVSIL_NORMAL); if IList <> 0 then begin if ImageList_GetIconSize(IList, W, H) then with Image1 do begin Width := W; Height := H; FillChar(Item, SizeOf(Item), 0); with Item do begin mask := TVIF_IMAGE or TVIF_HANDLE; { The first } hItem := Items[0].ItemId; end; if TreeView_GetItem(Handle, Item) then Picture.Icon.Handle := ImageList_GetIcon(IList, Item.iImage, ILD_NORMAL); end; end; end; end;
end.
|
|