Set an icon to my app

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
ne01982
Experienced Solver
Experienced Solver
Posts: 64
Joined: Sun Mar 25, 2007 6:09 pm

Set an icon to my app

Post by ne01982 » Sun May 06, 2007 6:52 pm

Hi everyone.

My main windown inherits from wxApp.

How can I change the icon off my app?

Thanks
Excuse my poor english ;)

JSThePatriot
Earned some good credits
Earned some good credits
Posts: 146
Joined: Sun Nov 26, 2006 7:37 am
Location: Tennessee, USA
Contact:

Re: Set an icon to my app

Post by JSThePatriot » Sun May 06, 2007 7:39 pm

ne01982 wrote:Hi everyone.

My main windown inherits from wxApp.

How can I change the icon off my app?

Thanks
It is different for different OS's. For windows you need a resource file. (appResources.rc or something ;))

My resource file

Code: Select all

aaaa ICON xpbn.ico

#include <wx/msw/wx.rc>
And again in the application just incase

Code: Select all

mainFrame->SetIcon( wxICON(aaaa) ); // To Set Application Icon
I have that in my MyApp::OnInit().

JS
OS Windows XP Pro
Compiler MinGW 3.4.5
wxWidgets 2.8.7 (Unicode : Monolithic : Release)
IDE Code::Blocks (Latest Release)
RAD wxFormBuilder (Latest Release)

BigFreeze
Earned some good credits
Earned some good credits
Posts: 109
Joined: Wed Sep 13, 2006 10:15 am
Location: Gebesee, Germany
Contact:

Post by BigFreeze » Mon May 07, 2007 9:39 am

Hi,

you can do also sth like that, it is nearly the same solution, JS posted before:

Code: Select all

#include "pics/icon.xpm"
and somewhere in OnInit() or the frame constructor:

Code: Select all

SetIcon(icon_xpm);
XPM files save the picture data in sth like a structure, and icon_xpm is its name.

Best regards, BigFreeze
It does not require a majority to prevail, but rather an irate, tireless minority keen to set brush fires in people's minds. (Samuel Adams)

OS: Windows XP Pro
Compiler: VC++ 8.0
wxWidgets: 2.8.0
IDE: VC++

JSThePatriot
Earned some good credits
Earned some good credits
Posts: 146
Joined: Sun Nov 26, 2006 7:37 am
Location: Tennessee, USA
Contact:

Post by JSThePatriot » Mon May 07, 2007 5:59 pm

BigFreeze wrote:Hi,

you can do also sth like that, it is nearly the same solution, JS posted before:

Code: Select all

#include "pics/icon.xpm"
and somewhere in OnInit() or the frame constructor:

Code: Select all

SetIcon(icon_xpm);
XPM files save the picture data in sth like a structure, and icon_xpm is its name.

Best regards, BigFreeze
Do you get that to work in Windows? I am unable to. I wish all the OS's could accept XPM's. It's a bit annoying trying to get each OS's icons worked out.

Thanks,
JS
OS Windows XP Pro
Compiler MinGW 3.4.5
wxWidgets 2.8.7 (Unicode : Monolithic : Release)
IDE Code::Blocks (Latest Release)
RAD wxFormBuilder (Latest Release)

BigFreeze
Earned some good credits
Earned some good credits
Posts: 109
Joined: Wed Sep 13, 2006 10:15 am
Location: Gebesee, Germany
Contact:

Post by BigFreeze » Tue May 08, 2007 7:26 am

Do you get that to work in Windows? I am unable to. I wish all the OS's could accept XPM's. It's a bit annoying trying to get each OS's icons worked out
.

Yes, it works fine with Windows and Linux. I have no problems.

I supposed, the acception of XPM's is a part, wxWidgets has to manage and not the OS. Maybe I'm wrong, but it seems, that XPM work better on different platforms than other types of images like JPEG, because it stores the data in sth like a structure. I think, to handle this kind of storage is part of the programs (picture editing software, I use GIMP) and not the OS.

Best regards, BigFreeze
It does not require a majority to prevail, but rather an irate, tireless minority keen to set brush fires in people's minds. (Samuel Adams)

OS: Windows XP Pro
Compiler: VC++ 8.0
wxWidgets: 2.8.0
IDE: VC++

JSThePatriot
Earned some good credits
Earned some good credits
Posts: 146
Joined: Sun Nov 26, 2006 7:37 am
Location: Tennessee, USA
Contact:

Post by JSThePatriot » Tue May 08, 2007 4:04 pm

I use it just as you have described, and for windows I still have to have a resource file if I want the icon in the task bar/manager. I would love if I am doing something wrong, and I dont need the resource file.

Thanks,
JS
OS Windows XP Pro
Compiler MinGW 3.4.5
wxWidgets 2.8.7 (Unicode : Monolithic : Release)
IDE Code::Blocks (Latest Release)
RAD wxFormBuilder (Latest Release)

Post Reply