简体   繁体   中英

How to use different icon size on delphi?

Does anybody knows how to use diferent icons sizes on delphi, I ask because the windows choose the best icon size when showing on explorer, But how do I put many icons in different sizes on resource.

Thanks again

Here's how I do it:

  1. Prepare an icon file with an icon editing program. This file is a .ico file and contains multiple versions of the same icon with different sizes and pixel formats.
  2. Reference that icon file in a .rc file that is used as source to the resource compiler.
  3. As part of the compilation, the .rc file is processed, resulting in a .res file.
  4. Link the .res file to the executable with a $R directive.
  5. At runtime load the appropriate version of the icon with one of the Windows API functions that loads images from resources.

I use these steps for all the icons that I use on toolbars and menus. That allows me to have a GUI that scales with the user's font scaling settings. The way that the Delphi IDE leads you to do it is to make a TImageList and fill it up with icons that are stored in the .dfm file. That's pretty hopeless because it doesn't readily allow you to have different sized icons. And it also means that your visual assets are stored in a .dfm file in a great big glob representing all icons. If you want to swap out a single icon, then you can do so but it's rather opaque. The history trail left in your VCS is meaningless beyond any comments you leave.

If you are just talking about the main program icon, then you can add your .ico file to the project in the Project | Options | Application dialog and the IDE will take care of the rest of the details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM