【发布时间】:2023-03-20 02:49:02
【问题描述】:
我正在尝试在 delphi2010 中向 VirtualTreeview 添加小图标 我使用属性图像将 ImageList 附加到 VirtualTreeview
procedure TMainFrm.VSTGetImageIndex(Sender: TBaseVirtualTree;
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
var Ghosted: Boolean; var ImageIndex: Integer);
var
FileInfo: PFileInfoRec;
begin
if Kind in [ikNormal , ikSelected] then
begin
if Column = 0 then
ImageIndex :=ImageList1.AddIcon(FileInfo.FileIco);
end;
end;
但添加图标后看起来太暗了:
FileInfo Strucutre (Record with methods) 当我加载文件时填充 我需要的只是将 fileico 从 fileinfo 添加到 imagelist 并显示在树视图中
type
PFileInfoRec= ^TFileInfoRec;
TFileInfoRec = record
strict private
vFullPath: string;
.
.
.
vFileIco : TIcon;
public
constructor Create(const FilePath: string);
property FullPath: string read vFullPath;
.
.
.
property FileIco : TIcon read vFileIco;
end;
构造函数:
constructor TFileInfoRec.Create(const FilePath: string);
var
FileInfo: SHFILEINFO;
begin
vFullPath := FilePath;
.
.
.
vFileIco := TIcon.Create;
vFileIco.Handle := FileInfo.hIcon;
// vFileIco.Free;
end;
那么问题在哪里? !谢谢
【问题讨论】:
-
看起来像部分透明度的问题。或许你需要将图片列表
ColorDepth设置为cd32Bit。 -
@DavidHeffernan 谢谢,但还是不行
-
好的,你到底做了什么?您究竟是什么时候更改了
ColorDepth?创建图像列表后立即。另外,您的真实代码是什么样的?大概真正的代码分配FileInfo。如果真实代码这样做,那么您发布虚假代码会令人失望。如果这是您的真实代码,那么不给FileInfo分配任何东西显然是个问题。 -
并且你不能每次树视图请求图像索引时都添加一个新图标。添加一次图标,每次返回相同的图片索引。
-
大卫说得对,在使用 Virtual TreeView 之前,您必须了解虚拟范式。
标签: delphi icons virtualtreeview