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:

Comments

Popular posts from this blog

Creating tray application and popup context menu in Windows

How to statically link applications to wxWidgets via Visual Studio 2008 and in Linux