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
This commit is contained in:
Vadim Zeitlin 2014-05-04 22:13:39 +00:00
parent cc73050b73
commit 29ff6f3e3b
2 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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;