I want to load an icon (from another file) which doesn t have multiple icons embedded in it (it s not an icon group). I don t know its size. I use now this code to retrieve the handle of the icon and use it with a TIcon.Handle:
function ResourceToIconHandle(hFile: hModule; IDname: PChar): HICON;
var
hGicon1,
hLoadIcon1: THandle;
pGIcon1: Pointer;
begin
hGicon1 := FindResource(hFile, IDName, RT_ICON);
if hGicon1 <> 0 then
begin
hLoadIcon1 := LoadResource(hFile, hGicon1);
pGicon1 := LockResource(hLoadIcon1);
Result := CreateIconfromResource(pGicon1,
SizeofResource(hFile, hGicon1),
True,
$00030000);
end;
end;
Yes, it s only a part of the code (if you want I ll show all). It works with only one problem: CreateIconfromResource function is giving me any icon streched at 32x32:
But I want to get the icons at their original resolution:
I know that CreateIconfromResource is designed to get them at the same resolution, that s why I m looking for another function. Thank you for your help.