How to Set Icon in a Windows Application using Visual Studio

12,753

From your comments, it sounds like you have multiple icon files set for your project. That's not going to work the way you want, or at least it's the really hard way of doing it.

The simple way is to let the operating system handle it for you. Create a single icon file that contains multiple icon sizes. 16x16, 32x32, 48x48, and 256x256 are the minimum sizes needed for current versions of Windows, but you can certainly add more (like 24x24 or 128x128) to improve pixel fidelity at those sizes if desired.

You can use Visual Studio to create the icons. Opening an .ico file should automatically open its icon resource editor. But I personally find it difficult or cumbersome to use. I highly recommend using a third-party program like IcoFX to create your icons and push pixels around.

Share:
12,753
S. Swaroop
Author by

S. Swaroop

Updated on June 16, 2022

Comments

  • S. Swaroop
    S. Swaroop almost 2 years

    I want to add an icon to my application. I have added an icon resource. and its working file for the first icon. That means after I have compiled, the 16x16 icon of the exe file is same as the icon file used. but when the explorer window is zoomed to large icon size, then the icon of the exe file vanishes and another blank default icon is displayed.

    How to set icon for large as well as small size display?

  • S. Swaroop
    S. Swaroop about 12 years
    ya I tried that. I created I ico file and added 16, 32 and 48 size icons using VS resource editor. but now the zoom can go upto 32 size but after that it goes back to default icon again. and also, in case if I move the exe file to desktop the icon becomes pixelated as if 16x16 has been streched ...and one more thing. in any case, if I left click on the exe file, the file information that is displayed in the bottom above the task bar shows the default icon.Tell me how to remove that.
  • Cody Gray
    Cody Gray about 12 years
    @S.Swaroop You have to recompile the application after you've told it to use the new icon file. I don't understand what you're trying to describe.
  • S. Swaroop
    S. Swaroop about 12 years
    ok . i explain again. I hv created an icon resource with different sizes i.e. 16x16, 32x32, 48x48, 128x128, 256x256 and all in 24 bit. now when I have compiled the application, the icon of the app displayed in the explorer window in "details" view is perfect. But when I change the view to "Large Icons" or "Medium Icons" the icons vanishes and default blank icon is displayed.
  • S. Swaroop
    S. Swaroop about 12 years
    ok I got it to display icons in large and extra large icons view, but not in medium icon view. I hv put sizes of 16x16, 32, 48, 64, 96, 128, 256 but still the medium view doesnt show the icon
  • S. Swaroop
    S. Swaroop about 12 years
    Solved. The windows was caching the icons. So when I renamed the app, the new icons are restored and blank icons were gone. but when I renamed it back to its original name, the blank icons are again displayed ....
  • Cody Gray
    Cody Gray about 12 years
    Hmm, yes later versions of Windows do cache icons. You'll find the file in (approximately) the following path: C:\Users\<User Name>\AppData\Local\IconCache.db from which it can be deleted to clear the icon cache and force it to be rebuilt. You can also disable it entirely from Windows Explorer if you like to play with icons.
  • NoPyGod
    NoPyGod about 12 years
    To clear cache quickly, change the colour depth of your screen/graphics adaptor, and then change it back.