Page 1 of 1

Problems setting an app icon

Posted: Wed Nov 07, 2007 1:55 am
by forrestcupp
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?

Posted: Wed Nov 07, 2007 2:47 am
by timg
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.

Posted: Wed Nov 07, 2007 3:38 am
by forrestcupp
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.

Posted: Wed Nov 07, 2007 3:51 am
by timg
just with a text editor.

Posted: Wed Nov 07, 2007 1:51 pm
by forrestcupp
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.

Posted: Wed Nov 07, 2007 3:18 pm
by Jorg
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

Posted: Wed Nov 07, 2007 5:44 pm
by timg
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 ..."

Posted: Wed Nov 07, 2007 5:53 pm
by timg
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.

Posted: Wed Nov 07, 2007 7:39 pm
by forrestcupp
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")));