Jump to content
  • Advertisement
Sign in to follow this  
Juliean

[C++]Setting icon for an exe

This topic is 2689 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,

I just wondered how to choose an icon for my compiled exe? I've got an application which I use normally use to replace icons, but these doesn't even work because my app hasn't even got a single icon. It's just that white box windows displays when somethings is wrong (missing files, etc..). How can I use an icon for my exe? I need it not to be updated at runtime, I just want to compile with icons. I'm using Visual C++ Studio 2010, regular c++ project (no form). Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Provided nothing has changed since I first learned about it (which was admittedly in the Win98 era), the icon used for the application is simply the icon with the lowest ID included in the executable's resource table.

Share this post


Link to post
Share on other sites
Provided nothing has changed since I first learned about it (which was admittedly in the Win98 era), the icon used for the application is simply the icon with the lowest ID included in the executable's resource table. [/quote]

Seems quite simple, but how do I use resources anyway? Didn't use them till know, and I checked the internet, but couldn't find much useful information. I tried right-clicking on my project and move over add, but then all I can do is add a class as "resource" is greyed out. Any idea? I'm using visual c++ studio 2010 express, maybe express can't handle resources (which I don't really think)..?

Share this post


Link to post
Share on other sites
Thanks, I tried it out. First I added the icon itself with Add Existing item and compiled. Didn't work. Then I noticed visual studio created a .rc file but didn't include in my project. I added it with Add Existing item, and studio told me that I can't edit resources with Visual studio express SKU. Seems that I need the professional edition to do so :/ Or is there any way around?

Share this post


Link to post
Share on other sites
Guest

Seems quite simple, but how do I use resources anyway? Didn't use them till know, and I checked the internet, but couldn't find much useful information. I tried right-clicking on my project and move over add, but then all I can do is add a class as "resource" is greyed out. Any idea? I'm using visual c++ studio 2010 express, maybe express can't handle resources (which I don't really think)..?


Yep, doesn't work to add resources in the express version. You will get icons added to the project only if you create a win32 project. However you can add some files manually to have icons in your project:

resource.h

#define IDI_PROJECTNAME 107
#define IDI_SMALL 108


projectname.rc (this is the file responsible for creating your resource table, will be automatically compiled, you don't need to include it anywhere)

#include "windows.h"
#include "resource.h"

IDI_PROJECTNAME ICON "projectname.ico"
IDI_SMALL ICON "small.ico"


projectname.ico (size should be 48x48)
small.ico (size should be 16x16)

Just replace "projectname" with your own project name.

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!