From 29ff6f3e3b612709d49f184e90bb3544ce6f86fe Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 May 2014 22:13:39 +0000 Subject: [PATCH] Fix resetting owner drawn radio buttons to normal state. Ensure that we bring the native button in sync with the real state of the radio button when we switch to normal state. Also avoid using BM_GETCHECK for the owner drawn buttons as we don't use BM_SETCHECK for them (as it's useless). See #10137. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76460 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/radiobut.h | 1 + src/msw/radiobut.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/wx/msw/radiobut.h b/include/wx/msw/radiobut.h index ad76fcf575..4f86e1eeef 100644 --- a/include/wx/msw/radiobut.h +++ b/include/wx/msw/radiobut.h @@ -60,6 +60,7 @@ protected: // Implement wxMSWOwnerDrawnButtonBase methods. virtual int MSWGetButtonStyle() const wxOVERRIDE; + virtual void MSWOnButtonResetOwnerDrawn() wxOVERRIDE; virtual int MSWGetButtonCheckedFlag() const wxOVERRIDE; virtual void MSWDrawButtonBitmap(wxDC& dc, const wxRect& rect, int flags) wxOVERRIDE; diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index cbb286bcf0..3737df1cc9 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -193,9 +193,12 @@ void wxRadioButton::SetValue(bool value) bool wxRadioButton::GetValue() const { - wxASSERT_MSG( m_isChecked == - (::SendMessage(GetHwnd(), BM_GETCHECK, 0, 0L) != 0), - wxT("wxRadioButton::m_isChecked is out of sync?") ); + if ( !IsOwnerDrawn() ) + { + wxASSERT_MSG( m_isChecked == + (::SendMessage(GetHwnd(), BM_GETCHECK, 0, 0L) != 0), + wxT("wxRadioButton::m_isChecked is out of sync?") ); + } return m_isChecked; } @@ -310,6 +313,13 @@ int wxRadioButton::MSWGetButtonStyle() const return BS_RADIOBUTTON; } +void wxRadioButton::MSWOnButtonResetOwnerDrawn() +{ + // ensure that controls state is consistent with internal state + ::SendMessage(GetHwnd(), BM_SETCHECK, + m_isChecked ? BST_CHECKED : BST_UNCHECKED, 0); +} + int wxRadioButton::MSWGetButtonCheckedFlag() const { return m_isChecked ? wxCONTROL_CHECKED : 0;