none
Embed multiple icons? RRS feed

  • Question

  • I've written an app that is compatible with all versions of Windows from XP to 10, but my icon isn't compatible with XP (Vista too?)

    Is it possible to embed multiple icons so when users right-click the exe's shortcut and select "Change Icon", they get more than one choice?

    I tried assigning the different icons to different forms, but my other forms don't display an icon (and I wouldn't want them showing the wrong icons anyway) so when I tried to change the icon, there was still only one choice. :(

    Thx.

    Friday, May 26, 2017 3:12 PM

Answers

  •  Your exe`s icon can contain only 1 image of each of the common sizes like 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256. There can only be 1 image of each size in an icon file unless you have added some that have a smaller color depth than 32bpp.

    Thank you for the reply,

    If I understand you, you are talking about a single ico file with multiple frames of different sizes and color depths?

    I'll look into that. Thx.

     Yes,  an Icon usually has at least 3 or 4 images ranging from 16x16 to 256x256.  The system decides which size to use according to the system settings.  Usually the images are the same image but,  just in the common sizes.  If i remember right,  i believe that the maximum size that XP will use is 48x48 and Vista up has a maximum of 256x256.

     For an example,  i made an icon that has 16x16,  24x24,  32x32,  48x48, and 256x256 images added to it.  Each image is the number that represents its size like 16,  24,  32,  48, and 256.  I then added the icon as the exe`s icon and the form`s icon.

     You can see in the image below,  the icon that the system uses for the Form is the 16x16.  However,  you can see that in the taskbar it uses the 32x32,  in the explorer window the 256x256,  and on the desktop the 48x48.  This is what i mean by the system will decide which of the icons image sizes to use for where it is being displayed and they will very depending on the system settings and explorer window`s view settings.

     

    If you say it can`t be done then i`ll try it

    Sunday, May 28, 2017 2:09 AM

All replies

  • You should show your code for others to see what does not work.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, May 26, 2017 3:20 PM
    Moderator
  • I've written an app that is compatible with all versions of Windows from XP to 10, but my icon isn't compatible with XP (Vista too?)

    Is it possible to embed multiple icons so when users right-click the exe's shortcut and select "Change Icon", they get more than one choice?

    I tried assigning the different icons to different forms, but my other forms don't display an icon (and I wouldn't want them showing the wrong icons anyway) so when I tried to change the icon, there was still only one choice. :(

    Thx.

    I doubt you'll do all of this but here's an idea:

    Create your own assembly (it will build to a .dll file). Inside that assembly - in the resources of it - put your icon files. The assembly will also have means of creating a subdirectory from the ApplicationData directory and for removing it also.

    Lastly, it will have a class that has the name of the icon, a boolean to indicate compatibility with XP, a partial file name (to combine with the temporary subdirectory later) and, if you have it, a small thumbnail preview bitmap of the icon.

    I think you can see where I'm going: With that you can present your users with the icon to choose in any number of ways and know, with confidence, what will be compatible.


    "A problem well stated is a problem half solved.” - Charles F. Kettering


    Friday, May 26, 2017 4:05 PM
  •  Your exe`s icon can contain only 1 image of each of the common sizes like 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256. There can only be 1 image of each size in an icon file unless you have added some that have a smaller color depth than 32bpp.  However,  newer systems will use the 32bpp icons instead of the ones with smaller color depths.  It is also the system settings that determine which icon out of those sizes to display on the desktop or in an explorer window.  So,  you will only get 1 icon to choose from,  the one that matches the color depth of the display and that also meets the systems size settings. 

     The only way i see it happening is if you distributed a separate icon with your application that the user can browse to and choose for the different shortcut icon via the shortcut file`s  properties as you asked about.

     If you just want to use different icons for different form`s,  then you can just set the Icon property of each form to a different icon file.


    If you say it can`t be done then i`ll try it

    Friday, May 26, 2017 5:01 PM
  •  Your exe`s icon can contain only 1 image of each of the common sizes like 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256. There can only be 1 image of each size in an icon file unless you have added some that have a smaller color depth than 32bpp.  However,  newer systems will use the 32bpp icons instead of the ones with smaller color depths.  It is also the system settings that determine which icon out of those sizes to display on the desktop or in an explorer window.  So,  you will only get 1 icon to choose from,  the one that matches the color depth of the display and that also meets the systems size settings. 

     The only way i see it happening is if you distributed a separate icon with your application that the user can browse to and choose for the different shortcut icon via the shortcut file`s  properties as you asked about.

     If you just want to use different icons for different form`s,  then you can just set the Icon property of each form to a different icon file.


    If you say it can`t be done then i`ll try it

    Oh I see that I misunderstood what he was asking about.

    I thought he wanted to distribute a bunch of icons and let the user choose which one to use.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, May 26, 2017 5:08 PM
  • Oh I see that I misunderstood what he was asking about.

    I thought he wanted to distribute a bunch of icons and let the user choose which one to use.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

     You never know,  maybe that is what OP wants?  I just thought it sounded like OP wanted to choose a different icon from his exe in the shortcut properties of their app.  8)

    If you say it can`t be done then i`ll try it

    Friday, May 26, 2017 5:40 PM

  •  You never know,  maybe that is what OP wants?  I just thought it sounded like OP wanted to choose a different icon from his exe in the shortcut properties of their app.  8)

    If you say it can`t be done then i`ll try it

    You're likely right.

    Who knows. ;-)


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Friday, May 26, 2017 5:41 PM
  • You should show your code for others to see what does not work.

    I'm not doing this in code. I need to know if there is way to make it part of the build.

    I know that some exe's contain multiple icons to choose from. I'm wondering if there are settings/options I am not aware of to do this in VS.

    Sunday, May 28, 2017 12:56 AM
  • I doubt you'll do all of this but here's an idea:

    Create your own assembly (it will build to a .dll file).

    Thank you for the reply.

    While I could create a dll containing icons, it would be just as easy to package several loose icon files in the archive and let the user choose from among them.

    I was hoping VS had a way to include multiple icons in the build and have the installer be smart enough to know which to use based on the OS.

    Wishful thinking I guess. :(

    Sunday, May 28, 2017 1:01 AM
  •  Your exe`s icon can contain only 1 image of each of the common sizes like 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256. There can only be 1 image of each size in an icon file unless you have added some that have a smaller color depth than 32bpp.

    Thank you for the reply,

    If I understand you, you are talking about a single ico file with multiple frames of different sizes and color depths?

    I'll look into that. Thx.

    Sunday, May 28, 2017 1:17 AM
  • Oh I see that I misunderstood what he was asking about.

    I thought he wanted to distribute a bunch of icons and let the user choose which one to use.


    "A problem well stated is a problem half solved.” - Charles F. Kettering

    My goal is an exe whose icon looks right regardless of the version of Windows.

    When installed under XP, my app has no icon (other than Windows default.) XP is unable to use the embedded 256x256x32b icon in my exe.

    It would be nice if there was also an XP compatible icon in the exe that appears when installed under that OS.

    Not a huge deal since there are so few XP users left, but why not if I can? :)

    Sunday, May 28, 2017 1:23 AM
  •  Your exe`s icon can contain only 1 image of each of the common sizes like 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, and 256x256. There can only be 1 image of each size in an icon file unless you have added some that have a smaller color depth than 32bpp.

    Thank you for the reply,

    If I understand you, you are talking about a single ico file with multiple frames of different sizes and color depths?

    I'll look into that. Thx.

     Yes,  an Icon usually has at least 3 or 4 images ranging from 16x16 to 256x256.  The system decides which size to use according to the system settings.  Usually the images are the same image but,  just in the common sizes.  If i remember right,  i believe that the maximum size that XP will use is 48x48 and Vista up has a maximum of 256x256.

     For an example,  i made an icon that has 16x16,  24x24,  32x32,  48x48, and 256x256 images added to it.  Each image is the number that represents its size like 16,  24,  32,  48, and 256.  I then added the icon as the exe`s icon and the form`s icon.

     You can see in the image below,  the icon that the system uses for the Form is the 16x16.  However,  you can see that in the taskbar it uses the 32x32,  in the explorer window the 256x256,  and on the desktop the 48x48.  This is what i mean by the system will decide which of the icons image sizes to use for where it is being displayed and they will very depending on the system settings and explorer window`s view settings.

     

    If you say it can`t be done then i`ll try it

    Sunday, May 28, 2017 2:09 AM
  • You can see in the image below,  the icon that the system uses for the Form is the 16x16.  However,  you can see that in the taskbar it uses the 32x32,  in the explorer window the 256x256,  and on the desktop the 48x48.  This is what i mean by the system will decide which of the icons image sizes to use

    Very cool & helpful. Thx.
    Sunday, May 28, 2017 11:28 AM