1

I'm trying to create a static bitmap but the constructor only accepts wxGDIImages. Here is the code from the FormBuilder:

wxStaticBitmap* tmtBitmap = new wxStaticBitmap( this, wxID_ANY, wxBitmap( wxT("directory"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );

Is there any way to convert the wxBitmap to a wxGDIImage? Or create a wxGDIImage given the directory?

Maybe there is another way to do this.

Thanks.

4

1 に答える 1

1

wxStaticBitmap does accept wxBitmap in its constructor (wx API-Doc)
The error message produced by the compiler might be a bit misleading im guessing you see something like this:

include/wx/msw/statbmp.h:80: note: candidates are: wxStaticBitmap::wxStaticBitmap(const wxStaticBitmap&)
include/wx/msw/statbmp.h:34: note:                 wxStaticBitmap::wxStaticBitmap(wxWindow*, wxWindowID, const wxGDIImage&, const wxPoint&, const wxSize&, long int, const wxString&)
include/wx/msw/statbmp.h:25: note:                 wxStaticBitmap::wxStaticBitmap()   


Since it is the only thing context depending, there seems to be a problem with your this pointer, either you are not "inside" a wxWindow or your compiler can't figure out the static type. You can use something like this to verify: (don't do that in productive code)

wxStaticBitmap* tmtBitmap = new wxStaticBitmap( (wxWindow*)NULL, wxID_ANY, wxBitmap( wxT("directory"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );

or

wxStaticBitmap* tmtBitmap = new wxStaticBitmap( (wxWindow*)this, wxID_ANY, wxBitmap( wxT("directory"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
于 2013-02-12T11:22:11.440 に答える