Thursday, September 03, 2009

wx widgets icon for your app

in windows build a file call main.rc with the following contents:

aaaaaaaaaaaaaaaa ICON "application_icon.ico"
application_icon ICON "application_icon.ico"
#define wxUSE_NO_MANIFEST 1
// set this to 1 if you don't want to
// use manifest resource (manifest resource
// is needed to enable visual styles on
// Windows XP - see docs/msw/winxp.txt
// for more information)
#include <wx/msw/wx.rc>

the windows compiler sets the first icon to be the .exe icon... and the 2nd is referenced in the code:

Then in your Frame constructor

#if !defined(__WXMSW__) && !defined(__WXPM__)
#include "application_icon.xpm"
SimpleMenu::SimpleMenu(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))

SetIcon( wxICON( application_icon ) );

you can use gimp to build your xpm and and ico files. If you rename your xpm file at all... edit it with a text editor and make sure the c string in it reads:
application_icon_xpm if the filename is application_icon.xpm

No comments: