How to put an image to wxPanel using wxWidgets
1. I created the class xOsdHeaderPanel
2. Must call the function wxInitAllImageHandlers();
3. Create a wxBitmap object and call SetBackgroundBitmap(..)
class xOsdHeaderPanel : public wxCustomBackgroundWindow<wxPanel>
{
public:
xOsdHeaderPanel(wxWindow* parent)
{
wxInitAllImageHandlers();
const wxSize xxsize(733,80);
Create(parent, wxID_ANY,wxDefaultPosition,xxsize);
wxBitmap bitmap(*new wxImage(wxT("./Header.png"),wxBITMAP_TYPE_PNG));
SetBackgroundBitmap(bitmap);
new wxButton(this,wxID_ANY,wxT("Sample Button"));
}
};
Result:
2. Must call the function wxInitAllImageHandlers();
3. Create a wxBitmap object and call SetBackgroundBitmap(..)
class xOsdHeaderPanel : public wxCustomBackgroundWindow<wxPanel>
{
public:
xOsdHeaderPanel(wxWindow* parent)
{
wxInitAllImageHandlers();
const wxSize xxsize(733,80);
Create(parent, wxID_ANY,wxDefaultPosition,xxsize);
wxBitmap bitmap(*new wxImage(wxT("./Header.png"),wxBITMAP_TYPE_PNG));
SetBackgroundBitmap(bitmap);
new wxButton(this,wxID_ANY,wxT("Sample Button"));
}
};
Result:
Comments
Post a Comment