我有一个组件。在组件中,我需要加载动态的 TImageList。
我今天使用这种方式,但在我所有的项目中,我需要一次添加所有图像。
function NavigatorImages: TImageList;
var
vIcon: TBitmap;
I: Integer;
begin
if FNavigatorImages = nil then
begin
vIcon := TBitmap.Create;
try
FNavigatorImages := TImageList.Create (nil);
FNavigatorImages.Height := 16;
FNavigatorImages.Width := 16;
for I := 0 to 11 do
begin
vIcon.LoadFromResourceName (HInstance, 'IMAGE_' + IntToStr(I));
FNavigatorImages.AddMasked (vIcon, vIcon.Canvas.Pixels[0, FNavigatorImages.Height - 1]);
end;
finally
vIcon.Free;
end;
end;
Result := FNavigatorImages;
end;
如何创建单个资源文件,例如包含多个图像可以加载到组件中而无需在每个项目中添加资源。你有办法吗?