我試着將PNG文件添加到TPngImageList(PngComponents for D7 got from http://code.google.com/p/cubicexplorer/downloads/list)。PngComponents:如何將PNG文件添加到TPngImageList
type
TImgListCrack = class(TPngImageList);
function LoadPngIconEx(ImageList: TPngImageList; const fn: string): boolean;
var
Icon: HICON;
AImage: TPngObject;
begin
with ImageList do
begin
BeginUpdate;
try
AImage:= TPngObject.Create;
AImage.LoadFromFile(fn);
Icon:= TImgListCrack(ImageList).PngToIcon(AImage);
ImageList_AddIcon(Handle, Icon);
DestroyIcon(Icon);
FreeAndNil(AImage);
Result:= true;
finally
EndUpdate;
end;
end;
end;
結果:圖標未添加,圖片列表仍爲空。如何做到這一點好嗎?
不,它不。沒有屬性TPngImageList中的項目,沒有方法添加w/out參數。 – Prog1020
的確,這是爲了TPngImageCollection。更改了TPngImageList的代碼。 –
U're在正確的軌道上。解決了。看到我的回覆。 – Prog1020