Fix wxSpinButton redrawing when using WS_EX_COMPOSITED

Explicitly redraw it ourselves instead of relying on DefWndProc() to do
it, as with 15e4f5b (Work around wxListCtrl repainting problems with
WS_EX_COMPOSITED, 2023-06-05) which did the same thing for wxListCtrl,
doing it seems to be enough to make the control draw correctly.

Closes #23656.
This commit is contained in:
Vadim Zeitlin 2023-07-08 20:24:54 +01:00
parent 0130a066df
commit 79567c83f4
2 changed files with 20 additions and 0 deletions

View file

@ -69,6 +69,8 @@ protected:
virtual void NormalizeValue();
private:
void OnPaint(wxPaintEvent& event);
wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxSpinButton);
};

View file

@ -23,6 +23,7 @@
#ifndef WX_PRECOMP
#include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
#include "wx/app.h"
#include "wx/dcclient.h"
#endif
#if wxUSE_SPINBTN
@ -130,6 +131,8 @@ bool wxSpinButton::Create(wxWindow *parent,
SubclassWin(m_hWnd);
Bind(wxEVT_PAINT, &wxSpinButton::OnPaint, this);
SetInitialSize(size);
return true;
@ -165,6 +168,21 @@ wxSize wxSpinButton::DoGetBestSize() const
return bestSize;
}
// ----------------------------------------------------------------------------
// painting
// ----------------------------------------------------------------------------
void wxSpinButton::OnPaint(wxPaintEvent& event)
{
// We need to always paint this control explicitly instead of letting
// DefWndProc() do it, as this avoids whichever optimization the latter
// function does when WS_EX_COMPOSITED is on that result in not drawing
// parts of the control at all (see #23656).
wxPaintDC dc(this);
wxSpinButtonBase::OnPaint(event);
}
// ----------------------------------------------------------------------------
// value and range
// ----------------------------------------------------------------------------