X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e1f36ff823aa21414b756cbe451853d1f1338fd9..24bd64eec17776d9f3ad4cabcd13697e56f568d1:/src/msw/button.cpp diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 5138afaf6d..daa665f297 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -30,6 +30,7 @@ #ifndef WX_PRECOMP #include "wx/button.h" #include "wx/brush.h" + #include "wx/panel.h" #endif #include "wx/msw/private.h" @@ -152,16 +153,31 @@ wxSize wxButton::GetDefaultSize() void wxButton::SetDefault() { wxWindow *parent = GetParent(); + wxButton *btnOldDefault = NULL; wxPanel *panel = wxDynamicCast(parent, wxPanel); if ( panel ) + { + btnOldDefault = panel->GetDefaultItem(); panel->SetDefaultItem(this); + } if ( parent ) { SendMessage(GetWinHwnd(parent), DM_SETDEFID, m_windowId, 0L); } - SendMessage(GetHwnd(), BM_SETSTYLE, BS_DEFPUSHBUTTON, 1L); + if ( btnOldDefault ) + { + // remove the BS_DEFPUSHBUTTON style from the other button + long style = GetWindowLong(GetHwndOf(btnOldDefault), GWL_STYLE); + style &= ~BS_DEFPUSHBUTTON; + SendMessage(GetHwndOf(btnOldDefault), BM_SETSTYLE, style, 1L); + } + + // set this button as the default + long style = GetWindowLong(GetHwnd(), GWL_STYLE); + style |= BS_DEFPUSHBUTTON; + SendMessage(GetHwnd(), BM_SETSTYLE, style, 1L); } // ----------------------------------------------------------------------------