Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6691227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:43:38+00:00 2026-05-26T05:43:38+00:00

I want to load an icon (from another file) which doesn’t have multiple icons

  • 0

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 32×32:

1

But I want to get the icons at their original resolution:
2

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:43:39+00:00Added an answer on May 26, 2026 at 5:43 am

    Use CreateIconFromResourceEx instead of CreateIconFromResource.

    CreateIconFromResourceEx lets you provide desired width/height, while CreateIconFromResource is using default system mertics for those (such as explained for LR_DEFAULTSIZE):

    Uses the width or height specified by the system metric values for
    cursors or icons, if the cxDesired or cyDesired values are set to
    zero. If this flag is not specified and cxDesired and cyDesired are
    set to zero, the function uses the actual resource size. If the
    resource contains multiple images, the function uses the size of the
    first image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to load some images into my application from the file system. There's
I want load ICON from exe's resource and draw it.
I want to load a desktop application, via reflection, as a Control inside another
I want to load 52 images (deck of cards) in gif format from my
I want to load some data from mysql into my cocoa application view before
I want to load defined folders into my website from same system, now I
I want to load key/values configuration pairs stored in XML file. To bind a
I have a System.Windows.Forms.Form and want to change the Form.Icon at runtime to display
I want to load AlphaSkin's Imagelist from resource. Commonly I know, how to load
I have a table list of promotions held in an NSSet which I load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.