Jump to content
  • Advertisement
Sign in to follow this  
XTAL256

Set icon for Windows app

This topic is 3704 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

How can i set my application's .exe icon in Visual Studio using resource (.rc) files? I have looked on MSDN but only found how to actually load an icon using LoadIcon. Isn't there some setting in VS to specify the icon? thanks.

Share this post


Link to post
Share on other sites
Advertisement
If you simply want to set application icon, then you don't need a *.rc file. You just include an icon into your project and build (compile) it. That's it. The icon will be shown for the executable file.

If you include multiple icons, then the first added icon will become the application icon.

Share this post


Link to post
Share on other sites
Ok, thanks. I thought it was something simple like that.
Mmm, i added my icon to the project (ProjectName -> Resource File -> Add -> Existing Item... then added my .ico file) but my exe doesn't have that icon. How do i get it to do that?

Share this post


Link to post
Share on other sites
Is your icon file valid? Make sure it's not a .bmp file that was renamed to .ico... Those will work for shortcuts, but they won't work with exes or dlls. Use a "proper" icon editor instead.

Share this post


Link to post
Share on other sites
Ha ha, no i'm pretty sure it's a proper .ico since i made it myself. Unless GIMP is the culprit (i made it in GIMP). It has a few bugs with .ico files but as far as i know they work with Windows. And it displays o.k. in explorer. It's 48x48 but that's ok right? I tried refreshing the view (F5) but that didn't work.

Share this post


Link to post
Share on other sites
Wait, which icon works and which doesnt? Explorer shows the icon for your application but you also want it to be in the upper left corner of the app window as well as the icon next to the title in the app's Taskbar button, right?

To add an icon so that Explorer shows it you simply add an icon to the resource file. Explorer will pick the icon with the smallest resource ID to show.

To add an icon to the window itself you need to either set it as hIcon or hIconSm in the WNDCLASSEX structure or send the window WM_SETICON. This assumes you are using straight up Win32. If you want more specifics you'll need to explain what language and framework you are using.

Share this post


Link to post
Share on other sites
When i said "And it displays o.k. in explorer", i meant the .ico file. The .exe still shows the default app icon.

EDIT: hey, guess what. I added the icon to the .rc file (100 ICON "Ballistic.ico") and it worked!
@songho: i guess i do need a .rc file. The strange thing is that i am not referring to it anywhere, i just id it by a number. VS must just pick the first icon i define as the application icon.

[Edited by - XTAL256 on April 3, 2008 4:03:22 AM]

Share this post


Link to post
Share on other sites
I was under the impression that explorer takes the first icon resource it finds in the .exe.
I other words it uses the first icon found in the .rc (in reality it's probably the icon with the lowest resource id).

Share this post


Link to post
Share on other sites
XTAL256,
Sorry for making you confused. You are right. You need a *.rc file for the application icon even if you don't reference it.

Apologies for false info.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!