procedure AddIconToImageList(aImageList: TImageList; const IconFileName: string);
var
ico: TIcon;
bmp: TBitmap;
begin
if not FileExists(IconFileName) then
raise Exception.Create('Archivo inexistente');
if UpperCase(ExtractFileExt(IconFilename)) <> '.ICO' then
raise Exception.Create('Tipo incorrecto de archivo');
ico := TIcon.Create;
try
ico.LoadFromFile(IconFileName);
bmp := TBitmap.Create;
try
bmp.PixelFormat := pf32bit;
bmp.Height := ico.Height;
bmp.Width := ico.Width;
bmp.Canvas.Draw(0, 0, ico);
aImageList.Add(bmp, nil);
finally
bmp.Free;
end;
finally
ico.Free;
end;
end;