我試圖小圖標在delphi2010 我有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;
連接到VirtualTreeview但增加的圖標後,添加到VirtualTreeview得很暗:
FileInfo Strucutre(記錄與方法)填充whene我加載文件,所以 我需要的僅僅是fileico添加到imagelist和d在樹狀isplay
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;
所以哪裏是probleme? !謝謝
看起來像部分透明的問題。也許你需要將圖像列表'ColorDepth'設置爲'cd32Bit'。 –
@DavidHeffernan謝謝,但仍然無法工作 –
好的,你到底做了什麼?當你改變了'ColorDepth'?立即在創建圖像列表之後。另外,你的真實代碼是什麼樣的?據推測,真正的代碼分配'FileInfo'。如果真實代碼這樣做,那麼你發佈虛假代碼令人失望。如果這是你真正的代碼,那麼不給'FileInfo'分配任何東西顯然是一個問題。 –