How to include BMP. ICO files in project
Posted: Wed Oct 15, 2008 5:42 pm
Hi i was wondering how to include resources like BMP , ICO and so on in the project ?
Code: Select all
<resource>
<object class="wxBitmap" name="my_image_name">/full/path/to/image/file</object>
</resource>
Code: Select all
resources.cpp: resources.xrc
<TAB>wxrc -c -v -o resources.cpp resources.xrc
Code: Select all
touch resources.xrc
Code: Select all
//at the top of your wxApp derived class, add this code
#include <wx/xrc/xmlres.h> // for wxXmlResource
extern void InitXmlResource();
bool MyApp::OnInit()
{
...
// inside your OnInit method of wxApp derived class, add this code
wxXmlResource::Get()->InitAllHandlers();
wxImage::AddHandler( new wxPNGHandler );
wxImage::AddHandler( new wxCURHandler );
wxImage::AddHandler( new wxICOHandler );
wxImage::AddHandler( new wxXPMHandler );
wxImage::AddHandler( new wxGIFHandler );
wxImage::AddHandler( new wxBMPHandler );
InitXmlResource();
...
}
Code: Select all
wxBitmap bmp = wxXmlResource::Get()->LoadBitmap(wxT("my_image_name"));