accessing bitmaps on an .xrc compiled into .cpp
personaje
personaje at gmail.com
Tue Oct 16 08:54:22 PDT 2007
On 10/16/07, Jason Dolan <jayson.dolan at gmail.com> wrote:
>
> On Oct 16, 1:07 am, person... at gmail.com (personaje) wrote:
> > Hello everyone!
> >
> > I have this .xrc file with a frame that has lots of controls with
> > <bitmap> childs... I use wxrc -c to create a .cpp file from the .xrc,
> > this creates a *big* .cpp with all the bitmaps as arrays, and code to
> > load these arrays into a wxMemoryFS:
> >
> > ----------code---------
> >
> > #if wxCHECK_VERSION(2,8,5) && wxABI_VERSION >= 20805
> > #define XRC_ADD_FILE(name, data, size, mime) \
> > wxMemoryFSHandler::AddFileWithMimeType(name, data, size, mime)
> > #else
> > #define XRC_ADD_FILE(name, data, size, mime) \
> > wxMemoryFSHandler::AddFile(name, data, size)
> > #endif
> >
> > static size_t xml_res_size_0 = 15046;
> > static unsigned char xml_res_file_0[] = {
> > 47,42,32,88,80,77,32,42,47,10,115,116,97,116,10 ... }
> >
> > XRC_ADD_FILE(wxT("XRC_resource/Seymour.cpp$bitmaps_raster.xpm"),
> > xml_res_file_0, xml_res_size_0, _T("image/x-xpixmap"));
> >
> > ----------end code---------
> >
> > I would like to be able to load these bitmaps as bitmaps objects, but
> > I can't, I use wxBitmap::LoadFile(wxT("memory:XRC_resource/Seymour.cpp$bitmaps_raster.xpm"))...
> >
> > What am I doing wrong? is it possible to do what I want?
> >
> > Regards.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscr... at lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-h... at li
>
> You should be able to do something like this (I've done this with
> other widgets... but not bitmaps. I'm assuming it'll work with bitmaps
> however):
>
> wxXmlResource::Get()->InitAllHandlers();
> InitXmlResource(); //Or whatever your xmlresource function is
> called within the dynamically generated cpp file
> wxFrame *pMyFrame;
> wxXmlResource::Get()->LoadFrame(pMyFrame, NULL,
> wxT("The_frames_name"));
> wxBitmap *pMyBitmap = XRCCTRL(*pMyFrame, "bitmap_name", wxBitmap);
>
nope, I get an invalid cast from wxWindow* to wxBitmap* : (
More information about the wx-users
mailing list