Jump to content

  • Log In with Google      Sign In   
  • Create Account


[C++]Setting icon for an exe


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Juliean   GDNet+   -  Reputation: 2248

Like
0Likes
Like

Posted 11 May 2011 - 05:23 AM

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!

Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 3695

Like
1Likes
Like

Posted 11 May 2011 - 05:38 AM

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.

#3 Juliean   GDNet+   -  Reputation: 2248

Like
0Likes
Like

Posted 11 May 2011 - 05:47 AM

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.


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)..?

#4 empirical2   Members   -  Reputation: 543

Like
1Likes
Like

Posted 11 May 2011 - 06:49 AM

Under 2008 its Project >> Add Existing Item (Or Project >> Add New Item >> Icon for new blank one)

#5 Juliean   GDNet+   -  Reputation: 2248

Like
0Likes
Like

Posted 11 May 2011 - 06:58 AM

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?

#6 LeChuckIsBack   Members   -  Reputation: 95

Like
0Likes
Like

Posted 11 May 2011 - 07:05 AM

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.
"Be it enacted by the General Assembly of the State of Indiana: It has been found that the circular area is to the quadrant of the circumference, as the area of an equilateral triangle is to the square of one side. The diameter employed as a linear unit according to the present rule in computing the circle's area is entirely wrong."




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS