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
LVL 2
BobcsiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vaceroseCommented:
From Windows API help

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.

0
Eddie ShipmanAll-around developerCommented:
From MSDN:
"Note  This function hase been superseded by the LoadImage function."

var
 hi: TIcon;
begin
 hi := TIcon.Create;
 try
   hi.Handle := LoadImage(hInst, MakeIntResource(ICON_NAME), IMAGE_ICON, 64, 64, LR_DEFAULTCOLOR);
   // Assign it...
 finally
   hi.Free;
 end;
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BobcsiAuthor Commented:
Thx

Fast answer

Solution:

image1.picture.icon.Handle:=loadimage(HInstance, 'ICON64',IMAGE_ICON,64,64,LR_LOADTRANSPARENT);

Bobcsi
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

BobcsiAuthor Commented:
New problem:)

Code:

var icon:TIcon;
begin
  icon:=ticon.create;
  icon.handle:=loadimage(HInstance, 'ICON64',IMAGE_ICON,64,64,LR_LOADTRANSPARENT);
  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
0
Eddie ShipmanAll-around developerCommented:
Please post your icon somewhere where I can download it. I can not create a 64x64 icon using the tools I have.
0
BobcsiAuthor Commented:
0
BobcsiAuthor Commented:
0
Eddie ShipmanAll-around developerCommented:
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
0
BobcsiAuthor Commented:
ok, posted.
0
Eddie ShipmanAll-around developerCommented:
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;
0
BobcsiAuthor Commented:
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
0
Eddie ShipmanAll-around developerCommented:
Do you REALLY need the image in the ImageList to be an ICON? Can't it be just a bitmap?
0
BobcsiAuthor Commented:
If i use a bitmap(64x64) i will get a ugly image.(bad shadow...etc)

Bobcsi
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.