From 88f04f551e68574f13592a4e6e0c4b992836976f Mon Sep 17 00:00:00 2001 From: Kvaz1r Date: Mon, 5 Aug 2019 15:21:10 +0300 Subject: [PATCH] Fix changing colours of wxSpinCtrl in wxMSW Ensure that the new colours are actually shown after Refresh() is called by refreshing the text part of the control as well, and not just the spin button. Closes https://github.com/wxWidgets/wxWidgets/pull/1468 Closes #12382. --- include/wx/msw/spinctrl.h | 2 ++ src/msw/spinctrl.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/wx/msw/spinctrl.h b/include/wx/msw/spinctrl.h index 8d7476344b..c81ed26665 100644 --- a/include/wx/msw/spinctrl.h +++ b/include/wx/msw/spinctrl.h @@ -65,6 +65,8 @@ public: virtual int GetBase() const; virtual bool SetBase(int base); + virtual void Refresh( bool eraseBackground = true, + const wxRect *rect = (const wxRect *) NULL ) wxOVERRIDE; // implementation only from now on // ------------------------------- diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 6c37d792db..6f1e8c7864 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -404,6 +404,19 @@ wxSpinCtrl::~wxSpinCtrl() gs_spinForTextCtrl.erase(GetBuddyHwnd()); } +void wxSpinCtrl::Refresh(bool eraseBackground, const wxRect *rect) +{ + wxControl::Refresh(eraseBackground, rect); + + UINT flags = RDW_INVALIDATE; + if ( eraseBackground ) + flags |= RDW_ERASE; + + // Don't bother computing the intersection of the given rectangle with the + // buddy control, just always refresh it entirely, as it's much simpler. + ::RedrawWindow(GetBuddyHwnd(), NULL, NULL, flags); +} + // ---------------------------------------------------------------------------- // wxSpinCtrl-specific methods // ----------------------------------------------------------------------------