Hey,
ich versuche grade verzweifelt Icons aus der System ImageList in meinem VirtualTreeView anzuzeigen. Doch leider bleiben die Symbole hartnäckig leer.
Aus meinem Testprojekt:
Delphi-Quellcode:
procedure InitialisiereIcons;
var SysIL : HImageList;
Info : TSHFileInfo;
SmallImages : TImageList;
begin
SmallImages := TImageList.Create(Form1);
SysIL := SHGetFileInfo('', 0, Info, SizeOf(TSHFileInfo),
SHGFI_SYSICONINDEX or SHGFI_SMALLICON);
if SysIL <> 0 then
begin
SmallImages.Handle := SysIL;
SmallImages.ShareImages := TRUE;
virtualstringtree1.Images := SmallImages;
end;
end;
Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var
Newitem : pvirtualnode;
nodedata: pnodedata;
Info : TSHFileInfo;
I: Integer;
begin
NewItem := virtualstringtree1.AddChild(nil);
nodedata := virtualstringtree1.GetNodeData(newitem);
nodedata^.Caption := 'test.pdf';
SHGetFileInfo(PChar(nodedata^.Caption)
,FILE_ATTRIBUTE_NORMAL, Info, SizeOf(TShFileInfo),
SHGFI_SYSICONINDEX or SHGFI_USEFILEATTRIBUTES);
nodedata^.ImageIndex := Info.IIcon;
end;
Delphi-Quellcode:
procedure TForm1.VirtualStringTree1GetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
var
NodeData: PNodeData;
begin
NodeData := VirtualStringTree1.GetNodeData(Node);
if assigned(nodedata) then
begin
imageindex := nodedata^.imageindex;
end;
end;
procedure TForm1.VirtualStringTree1GetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: string);
var
NodeData: PNodeData;
begin
NodeData := VirtualStringTree1.GetNodeData(Node);
if assigned(nodedata) then
begin
celltext := nodedata^.Caption;
end;
end;
Selber Code in einem TListView funktioniert wunderbar
Viele Grüße
Zacherl