Discussion:
[XP] How to attach an icon ?
Francis Courtois
2004-04-19 18:49:25 UTC
Permalink
I am new to wxWidget and have to face several issues. My main OS is win
XP (although I use a lot Linux). I use MinGW and related gcc + wxWidgets
2.4.2.

Among these, how to attach an icon to my software in win XP ?

I have tried sample code but it didn't work.

Thanks
Aj Lavin
2004-04-20 00:21:41 UTC
Permalink
Post by Francis Courtois
I am new to wxWidget and have to face several issues. My main OS is win
XP (although I use a lot Linux). I use MinGW and related gcc + wxWidgets
2.4.2.
Among these, how to attach an icon to my software in win XP ?
Add this line to the beginning of your .rc file:

aaaa ICON "myIconFile.ico"

This seems to work on all versions of MS Windows.

HTH,

AJ

PS: Your reply-to address appears to be broken.
Francis Courtois
2004-04-20 07:00:54 UTC
Permalink
I did that, but what else should I do apart from creating this file ?
Should I modify something in the makefile ? Do I need to name this file
the same name.rc as name.exe ?

Thnaks

PS: my wrong email address is supposed to avoid spamming !
Post by Aj Lavin
Post by Francis Courtois
I am new to wxWidget and have to face several issues. My main OS is win
XP (although I use a lot Linux). I use MinGW and related gcc + wxWidgets
2.4.2.
Among these, how to attach an icon to my software in win XP ?
aaaa ICON "myIconFile.ico"
This seems to work on all versions of MS Windows.
HTH,
AJ
PS: Your reply-to address appears to be broken.
---------------------------------------------------------------------
Aj Lavin
2004-04-20 07:48:38 UTC
Permalink
Post by Francis Courtois
I did that, but what else should I do apart from creating this file ?
Should I modify something in the makefile ? Do I need to name this file
the same name.rc as name.exe ?
The name of the resource file is arbitrary. But you need to build it and
link it to your app. How you should do that depends on the tools you are
using.

I use mingw and here are the parts of my makefile that have to do with
the resource file:

RC = windres
RCINCSWITCH=--include-dir
RCDEFSWITCH=--define
RESFLAGS=$(RCINCSWITCH) $(WXDIR)/include $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__
resources.o: resources.rc WinXp.manifest
$(RC) -i resources.rc -o resources.o $(RESFLAGS)

You can link the .o file like any other object:

$(TARGET): ${ALLOBJECTS} $(MY_LIBS)
$(CC) -o $(TARGET) ${ALLOBJECTS} resources.o $(LIBS)

My resources.rc looks like this:

aaaa ICON "rc/Icons/myicon.ico"
#include "wx/msw/wx.rc"
1 24 "WinXp.manifest"

Info on the Windows XP manifest file is here:

http://www.wxwindows.org/faqmsw.htm#winxp

HTH,

Aj
Post by Francis Courtois
PS: my wrong email address is supposed to avoid spamming !
I should have guessed. :-)
Francis Courtois
2004-04-20 10:23:34 UTC
Permalink
I did everything as you proposed... but still no icon on windows nor in
the app itself.

Here is my resources.rc
#include "wx/msw/wx.rc"
A ICON "mondrian.ico"
ICONPRG ICON "mondrian.ico"

Also, part of my code:

#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "mondrian.xpm"
#endif

MyFrame::MyFrame(wxWindow* parent)
{
wxXmlResource::Get()->LoadFrame(this, parent, wxT("frame_1"));

SetIcon(wxICON(mondrian));

CreateStatusBar( 1 );
}
Post by Aj Lavin
Post by Francis Courtois
I did that, but what else should I do apart from creating this file ?
Should I modify something in the makefile ? Do I need to name this file
the same name.rc as name.exe ?
The name of the resource file is arbitrary. But you need to build it and
link it to your app. How you should do that depends on the tools you are
using.
I use mingw and here are the parts of my makefile that have to do with
RC = windres
RCINCSWITCH=--include-dir
RCDEFSWITCH=--define
RESFLAGS=$(RCINCSWITCH) $(WXDIR)/include $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__
resources.o: resources.rc WinXp.manifest
$(RC) -i resources.rc -o resources.o $(RESFLAGS)
$(TARGET): ${ALLOBJECTS} $(MY_LIBS)
$(CC) -o $(TARGET) ${ALLOBJECTS} resources.o $(LIBS)
aaaa ICON "rc/Icons/myicon.ico"
#include "wx/msw/wx.rc"
1 24 "WinXp.manifest"
http://www.wxwindows.org/faqmsw.htm#winxp
HTH,
Aj
Post by Francis Courtois
PS: my wrong email address is supposed to avoid spamming !
I should have guessed. :-)
---------------------------------------------------------------------
Francis Courtois
2004-04-20 10:45:33 UTC
Permalink
Sorry. I wrote a mistake: your solution works fine for winXP.

Unfortunatly it still doesnt work to make the icon appear on topleft of
my frame. Any idea ?

Here is my resources.rc
#include "wx/msw/wx.rc"
A ICON "mondrian.ico"
ICONPRG ICON "mondrian.ico"

Also, part of my code:

#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "mondrian.xpm"
#endif

MyFrame::MyFrame(wxWindow* parent)
{
wxXmlResource::Get()->LoadFrame(this, parent, wxT("frame_1"));

SetIcon(wxICON(mondrian));

CreateStatusBar( 1 );
}
Post by Aj Lavin
Post by Francis Courtois
I did that, but what else should I do apart from creating this file ?
Should I modify something in the makefile ? Do I need to name this file
the same name.rc as name.exe ?
The name of the resource file is arbitrary. But you need to build it and
link it to your app. How you should do that depends on the tools you are
using.
I use mingw and here are the parts of my makefile that have to do with
RC = windres
RCINCSWITCH=--include-dir
RCDEFSWITCH=--define
RESFLAGS=$(RCINCSWITCH) $(WXDIR)/include $(RCDEFSWITCH) __WIN32__ $(RCDEFSWITCH) __WIN95__ $(RCDEFSWITCH) __GNUWIN32__
resources.o: resources.rc WinXp.manifest
$(RC) -i resources.rc -o resources.o $(RESFLAGS)
$(TARGET): ${ALLOBJECTS} $(MY_LIBS)
$(CC) -o $(TARGET) ${ALLOBJECTS} resources.o $(LIBS)
aaaa ICON "rc/Icons/myicon.ico"
#include "wx/msw/wx.rc"
1 24 "WinXp.manifest"
http://www.wxwindows.org/faqmsw.htm#winxp
HTH,
Aj
Post by Francis Courtois
PS: my wrong email address is supposed to avoid spamming !
I should have guessed. :-)
---------------------------------------------------------------------
Aj Lavin
2004-04-20 12:08:06 UTC
Permalink
Post by Francis Courtois
Sorry. I wrote a mistake: your solution works fine for winXP.
Ok. To be clear, what I showed you how to do was to set the application
icon. This is the icon that is displayed by Explorer when listing the
directory that contains your program.
Post by Francis Courtois
Unfortunatly it still doesnt work to make the icon appear on topleft of
my frame. Any idea ?
Ok, setting the frame icon is what wxFrame::SetIcon is for. But there is
slight problem with the code.
Post by Francis Courtois
Here is my resources.rc
#include "wx/msw/wx.rc"
A ICON "mondrian.ico"
ICONPRG ICON "mondrian.ico"
You have no resource named "mondrian"..
Post by Francis Courtois
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "mondrian.xpm"
#endif
MyFrame::MyFrame(wxWindow* parent)
{
wxXmlResource::Get()->LoadFrame(this, parent, wxT("frame_1"));
SetIcon(wxICON(mondrian));
.. and here (on wxMSW) wxICON is trying to load an icon resource named
"mondrian". In your resources file, change "ICONPRG" to "mondrian", and
then your code should work on all platforms.

HTH,

Aj
Francis Courtois
2004-04-20 22:02:37 UTC
Permalink
Thank you very much !

Now I have my icon both in winXP on on topleft of my frame.

Thanks for the time spent helping me.
Post by Aj Lavin
Post by Francis Courtois
Sorry. I wrote a mistake: your solution works fine for winXP.
Ok. To be clear, what I showed you how to do was to set the application
icon. This is the icon that is displayed by Explorer when listing the
directory that contains your program.
Post by Francis Courtois
Unfortunatly it still doesnt work to make the icon appear on topleft of
my frame. Any idea ?
Ok, setting the frame icon is what wxFrame::SetIcon is for. But there is
slight problem with the code.
Post by Francis Courtois
Here is my resources.rc
#include "wx/msw/wx.rc"
A ICON "mondrian.ico"
ICONPRG ICON "mondrian.ico"
You have no resource named "mondrian"..
Post by Francis Courtois
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "mondrian.xpm"
#endif
MyFrame::MyFrame(wxWindow* parent)
{
wxXmlResource::Get()->LoadFrame(this, parent, wxT("frame_1"));
SetIcon(wxICON(mondrian));
.. and here (on wxMSW) wxICON is trying to load an icon resource named
"mondrian". In your resources file, change "ICONPRG" to "mondrian", and
then your code should work on all platforms.
HTH,
Aj
---------------------------------------------------------------------
Patrick Valeri
2004-04-20 08:22:17 UTC
Permalink
For example:
wxIcon= *icon= new wxIcon(;
icon->LoadFile("MyIcon.ico",wxBITMAP_TYPE_ICO);
frame->SetIcon(*icon);//It appears at the bottom left of your window
What's the matter?I don't understand easily
Regards
-----Message d'origine-----
De : Francis Courtois [mailto:***@_NoSpam_fcourtois.com]
Envoye : mardi 20 avril 2004 09:01
A : wx-***@lists.wxwidgets.org
Objet : Re: [XP] How to attach an icon ?



I did that, but what else should I do apart from creating this file ?
Should I modify something in the makefile ? Do I need to name this file
the same name.rc as name.exe ?

Thnaks

PS: my wrong email address is supposed to avoid spamming !
Post by Aj Lavin
Post by Francis Courtois
I am new to wxWidget and have to face several issues. My main OS is win
XP (although I use a lot Linux). I use MinGW and related gcc + wxWidgets
2.4.2.
Among these, how to attach an icon to my software in win XP ?
aaaa ICON "myIconFile.ico"
This seems to work on all versions of MS Windows.
HTH,
AJ
PS: Your reply-to address appears to be broken.
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-***@lists.wxwidgets.org
For additional commands, e-mail: wx-users-***@lists.wxwidgets.org
Francis Courtois
2004-04-20 09:53:21 UTC
Permalink
The problem is just in winXP itself where i couldn't have my program
shown with its icon in win explorer.
Post by Patrick Valeri
wxIcon= *icon= new wxIcon(;
icon->LoadFile("MyIcon.ico",wxBITMAP_TYPE_ICO);
frame->SetIcon(*icon);//It appears at the bottom left of your window
What's the matter?I don't understand easily
Regards
-----Message d'origine-----
Envoye : mardi 20 avril 2004 09:01
Objet : Re: [XP] How to attach an icon ?
I did that, but what else should I do apart from creating this file ?
Should I modify something in the makefile ? Do I need to name this file
the same name.rc as name.exe ?
Thnaks
PS: my wrong email address is supposed to avoid spamming !
Post by Aj Lavin
Post by Francis Courtois
I am new to wxWidget and have to face several issues. My main OS is win
XP (although I use a lot Linux). I use MinGW and related gcc + wxWidgets
2.4.2.
Among these, how to attach an icon to my software in win XP ?
aaaa ICON "myIconFile.ico"
This seems to work on all versions of MS Windows.
HTH,
AJ
PS: Your reply-to address appears to be broken.
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
Loading...