Problems setting an app icon Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Problems setting an app icon

Post by forrestcupp » Wed Nov 07, 2007 1:55 am

I am using Visual C++ 2005 Express which doesn't allow resource editing. When I create a wxWidgets project, it never even creates a rc or res file to edit.

So I am trying to use the SetIcon function on my frame and the compiler never gives any errors, but it also never shows an icon in my title bar and task bar.

Does anyone have any ideas on how I can get an app icon to display?

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Wed Nov 07, 2007 2:47 am

I'm using Visual C++ 2003, not 2005, but what I did was create
a .rc file with same name as solution and put this inside:

Code: Select all

anIcon ICON klp.ico
#include "wx\msw\wx.rc"
then in the frame constructor, used this code

Code: Select all

	frame->SetIcon(wxICON(anIcon));
Is that what you tried?

I also added the .rc file to my solution.

forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Post by forrestcupp » Wed Nov 07, 2007 3:38 am

Thank you for your quick reply. How do you create your rc file? Are you using the Express version or the Pro version? In my express version I can't edit or create rc files.

Maybe I can do this with a third party resource editor.

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Wed Nov 07, 2007 3:51 am

just with a text editor.

forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Post by forrestcupp » Wed Nov 07, 2007 1:51 pm

Ok, I'll try that. But I don't have any experience with rc files, so I have a couple of questions for you.

Where you entered klp.ico, should I substitute the name of the file I want to use, or does it need to say klp.ico?

Can I make the rc file with only those two lines, or does it need to have more things in it?

If I just save this file to my project's directory, will it automatically be added to the project? edit: I actually just tried it, and it doesn't add it automatically. In the Express version, I can't even figure out how to add an rc file.

Thanks again.

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Nov 07, 2007 3:18 pm

A small piece of additional information, if your icon still does not show up, rename it to AAAAAAAAAAAAA as constant. Somehow Windows takes the first icon in the resource (with the first alphabetic name) to be the icon name for the main window.

Regards.
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Wed Nov 07, 2007 5:44 pm

forrestcupp wrote:Ok, I'll try that. But I don't have any experience with rc files, so I have a couple of questions for you.

Where you entered klp.ico, should I substitute the name of the file I want to use, or does it need to say klp.ico?

Can I make the rc file with only those two lines, or does it need to have more things in it?

If I just save this file to my project's directory, will it automatically be added to the project? edit: I actually just tried it, and it doesn't add it automatically. In the Express version, I can't even figure out how to add an rc file.

Thanks again.
Yes, change klp.ico to your file name. Those are the only 2 lines in my .rc file.

In Visual C++, I believe I just right-clicked on the project in the browser and did an "Add existing ..."

timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Wed Nov 07, 2007 5:53 pm

If you still have trouble, check this link.

http://www.gamedev.net/community/forums ... _id=457396

there seem to be some links to resource editors there. I haven't tried any of them though.

forrestcupp
Earned some good credits
Earned some good credits
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Post by forrestcupp » Wed Nov 07, 2007 7:39 pm

timg wrote:
Yes, change klp.ico to your file name. Those are the only 2 lines in my .rc file.

In Visual C++, I believe I just right-clicked on the project in the browser and did an "Add existing ..."
Thanks! You're awesome. I didn't realize I could add an existing item and it would accept an rc file. I created an rc file using notepad and I substituted my icon file for what you had, and it worked.

Thank you.

Edit:
Just for future reference, I have to do this, which is slightly different from what I was told.

Code: Select all

frame->SetIcon(wxIcon(_T("anIcon")));

Post Reply