How can I add bitmap to dialog?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
AndrzejB
Experienced Solver
Experienced Solver
Posts: 76
Joined: Sun Nov 29, 2015 12:46 pm

How can I add bitmap to dialog?

Post by AndrzejB » Tue Sep 22, 2020 12:08 pm

I try own message box like wxMessageBox.
How can I add bitmap to dialog?
is posssible add bitmap to button:

Code: Select all

 const wxSize imageSize(32, 32);
    wxImageList*  m_imageList = new wxImageList();
    m_imageList = new wxImageList(imageSize.GetWidth(), imageSize.GetHeight());
    m_imageList->
            Add(wxArtProvider::GetIcon(wxART_INFORMATION, wxART_OTHER, imageSize));
    m_imageList->
            Add(wxArtProvider::GetIcon(wxART_QUESTION, wxART_OTHER, imageSize));
    m_imageList->
            Add(wxArtProvider::GetIcon(wxART_WARNING, wxART_OTHER, imageSize));
    m_imageList->
            Add(wxArtProvider::GetIcon(wxART_ERROR, wxART_OTHER, imageSize));
    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
    wxButton *button = new wxButton(this, 1, "");
    button->SetBitmap(m_imageList->GetBitmap(0));
    sizer->Add(button);
    SetSizer(sizer);
I try using panel https://wiki.wxwidgets.org/An_image_panel after correcting "wxImagePanel: public wxPanel" and "wxImagePanel(wxWindow* parent, wxString file, wxBitmapType format)" I don't see image on this panel.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2580
Joined: Sun Jan 03, 2010 5:45 pm

Re: How can I add bitmap to dialog?

Post by PB » Tue Sep 22, 2020 1:00 pm

If the bitmap is relatively small and you do not need to scale it, I recommend taking a look at wxStaticBitmap control.

Post Reply