Jump to content
  • Advertisement
Sign in to follow this  
iNsAn1tY

Silly little Win32 problem... [Solved]

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone. I'd like to add a custom icon to my application. I have the icon made (it's a 32-bit Windows XP one, made from a PNG file, with alpha-mask transparency). I've managed to get my program using the icon when it runs (ie. on the task switch bar), using the LoadImage() API call when I'm defining my main window's window class. However, the program's actual icon hasn't changed from the default one that Visual Studio gave it when it created my project. Does anyone know how I can force my program's icon to be changed with a recompile? I'm assuming that there's some obscure thing I'll have to do with my resource file, or some registry key I'll have to delete? I have had a look in MSDN, but I haven't found anything relevant. Also, the Visual Studio icon editor insists on mangling my icon when it loads it, removing any alpha transparency, and dropping it to 16 colours. Any way around this? Thanks in advance for any replies... [Edited by - iNsAn1tY on June 21, 2005 11:30:19 AM]

Share this post


Link to post
Share on other sites
Advertisement
Since with images as small as icons general scaling and resampling gives bad results, multiple icons are usually defined in a program -- one for each icons size (i.e. small in the application title bar, larger in the task bar perhaps, yet larger in a menu) and color settings (16, 256, 16-bit, etc). So for the first part of your question: use your resource editor to support as many types and formats as you can, such that Windows can select the appropriate icon to pick. Probably some of the formats still show the original icon.

As for the transparency removal: this may well be because Windows stores icon in a BMP-like format. Since BMP does not support transparency (well at least not in icons) it is faked by setting some color to transparent. This is best done in the resource editor, replacing the PNG-transparent areas with the BMP-transparent color key.

I hope this is all clear and also I hope it is correct -- it has been a while. Please try some of this and let me/us know. Greetz,

Illco

Share this post


Link to post
Share on other sites
If you're talking about the icon Explorer uses to display the exe, it has something to do with alphabetical order of the resource identifiers, the first suitable icon is used.

Try changing your icon's res ID so that it is alphabetically first.

And I don't think MSVC's res editor supports 32-bit icons, try a shareware program called IconLover if all else fails, it saves 32-bit .ico files with multiple sizes and all that other neat stuff.

Share this post


Link to post
Share on other sites
I thought it was not alphabetically, but the first ID you assigned (so numerically).

Share this post


Link to post
Share on other sites
Problem solved, thanks guys. The icon assigned to the executable at compile time is the one with the lowest resource ID. I just opened the resource file, changed the filename to point to my icon, then made sure that the resource ID for that icon was the lowest in resource.h. Job done. Best of all, I didn't have to load it into Visual Studio and lose all the fancy transparency [grin]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!