When looking into the topic, on Windows I encountered something I think may be a bug (Windows 10, wxWidgets master)?
The code draws a logo in the top left corner, which is not scrolled with the controls. When I do not call EnableScrolling(false, false), there are drawing artifacts. This is expected because Windows will just move the window area including the bitmap. So EnableScrolling(false, false) has to be called.
However when EnableScrolling(false, false) is called, the controls are not properly redrawn after the scrolling. They scrolling result shows only after I resize the frame. I find this unexpected, I believe calling EnableScrolling() should not have any effect on this. The issue is present regardless of binding the paint event or creating m_scrolled with wxFULL_REPAINT_ON_RESIZE, only EnableScrolling() call affects this.
Code: Select all
class MyFrame: public wxFrame
MyFrame() : wxFrame (nullptr, wxID_ANY, "Test")
wxSizer* scrolledSizer = new wxBoxSizer(wxVERTICAL);
m_scrolled = new wxScrolledWindow(this);
for ( size_t i = 0; i < 50; ++i )
scrolledSizer->Add(new wxButton(m_scrolled, wxID_ANY, wxString::Format("Button %zu", i)), wxSizerFlags().Center().Border());
m_scrolled->Bind(wxEVT_PAINT, &MyFrame::OnPaintScrolled, this);
m_logoBitmap = wxArtProvider::GetBitmap(wxART_INFORMATION);
dc.DrawBitmap(m_logoBitmap, 0, 0);
class MyApp : public wxApp
bool OnInit() override
The same happens on Ubuntu and reading EnableScrolling() docs, I may have misunderstood what it does. I thought it basically only speeds-up drawing by reusing the scrolled part of the window and drawing only the newly uncovered one.
On Ubuntu, there are no artifacts even without calling EnableScrolling(false, false). I guess it does not do what ScrollWindowEx() does on MSW, i.e., reusing the scrolled part?
It was bugging me so I asked in wx-users: https://groups.google.com/u/1/g/wx-users/c/9Ww1ACmJG4k
Based on the answer from the "main" wxWidgets developer, this may not be possible:
https://groups.google.com/g/wx-users/c/ ... B9FPMIBQAJ