The ResourceLoad
and GetResource
methods load the entire image list from the single specified image resource. The intent is that you would have a single bitmap holding all the images meant to go in the list. The control then slices it up into separate tiles based on the image list's configured width and height.
With that in mind, you might have expected the image list to simply load your icon and be left with just that single image in the list. But image lists are only allowed to load bitmap resources. They won't load icon resources. (The resource-type parameter is there to leave open the possibility of some future expansion of its capabilities.) See the ImageList_LoadImage
API function for details.
It looks like you didn't want to load the entire image list anyway. It appears you wished to append an icon to the list of images already in the list. In that case, your method calling LoadImage
is fine. TIcon
knows how to load things from resources itself, so your code can be a little more streamlined:
myicon := TIcon.Create;
try
myicon.LoadFromResourceName(HInstance, 'TEXT_BOLD');
FImageList.AddIcon(myicon);
finally
myicon.Free;
end;