Bobcsi
asked on
Load a large icon from resource
Hi!
I want load a icon from resource to a TImage or TImagelist.
I have a ICON64 icon resource. Size: 64 x 64.
When load icon, i get the icon, but size is 32 x 32. Why?
Code:
image1.picture.icon.Handle :=loadicon (HInstance , 'ICON64');
Thx the answers
Bobcsi
I want load a icon from resource to a TImage or TImagelist.
I have a ICON64 icon resource. Size: 64 x 64.
When load icon, i get the icon, but size is 32 x 32. Why?
Code:
image1.picture.icon.Handle
Thx the answers
Bobcsi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thx
Fast answer
Solution:
image1.picture.icon.Handle :=loadimag e(HInstanc e, 'ICON64',IMAGE_ICON,64,64, LR_LOADTRA NSPARENT);
Bobcsi
Fast answer
Solution:
image1.picture.icon.Handle
Bobcsi
ASKER
New problem:)
Code:
var icon:TIcon;
begin
icon:=ticon.create;
icon.handle:=loadimage(HIn stance, 'ICON64',IMAGE_ICON,64,64, LR_LOADTRA NSPARENT);
imagelist1.AddIcon(icon);
image1.picture.icon.assign (icon);
end;
When run AddIcon a get an error: "invalid image size"
Because I set the imagelist1 width,height to 64.
Why?
Bobcsi
Code:
var icon:TIcon;
begin
icon:=ticon.create;
icon.handle:=loadimage(HIn
imagelist1.AddIcon(icon);
image1.picture.icon.assign
end;
When run AddIcon a get an error: "invalid image size"
Because I set the imagelist1 width,height to 64.
Why?
Bobcsi
Please post your icon somewhere where I can download it. I can not create a 64x64 icon using the tools I have.
ASKER
ASKER
I can not get to that server, can't figure out why, would you just email it to eddie dot shipman at gmail dot com
ASKER
ok, posted.
Somewhere between setting the icon's height/width and the CheckImage function in ImgList, the height/width gets reset to
32x32. I'll see if I can figure out why.
Loading into a TImage is no problem load it into the TImage before trying to load it to the ImageList.
Here is how I rearranged it:
var
icon: TIcon;
begin
icon := ticon.create;
icon.Height := 64;
icon.Width := 64;
icon.handle := loadimage(HInstance, 'ICON64', IMAGE_ICON, 64, 64, LR_LOADTRANSPARENT);
image1.picture.icon.assign (icon);
// Still gettting the Invalid image size error here
imagelist1.AddIcon(icon);
end;
32x32. I'll see if I can figure out why.
Loading into a TImage is no problem load it into the TImage before trying to load it to the ImageList.
Here is how I rearranged it:
var
icon: TIcon;
begin
icon := ticon.create;
icon.Height := 64;
icon.Width := 64;
icon.handle := loadimage(HInstance, 'ICON64', IMAGE_ICON, 64, 64, LR_LOADTRANSPARENT);
image1.picture.icon.assign
// Still gettting the Invalid image size error here
imagelist1.AddIcon(icon);
end;
ASKER
I think, the problem: I load an icon (size: 64 x 64) into Ticon, but after it, i get the TIcon.Width and this value is 32. But Why?
And ImageList accept only 64x64 icon
Idea?:(
Bobcsi
And ImageList accept only 64x64 icon
Idea?:(
Bobcsi
Do you REALLY need the image in the ImageList to be an ICON? Can't it be just a bitmap?
ASKER
If i use a bitmap(64x64) i will get a ugly image.(bad shadow...etc)
Bobcsi
Bobcsi
LoadIcon can only load an icon whose size conforms to the SM_CXICON and SM_CYICON system metric values. Use the LoadImage function to load icons of other sizes.