X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4e9da8b79e9218bf194f70af9b5ad706967c0099..24e35cf87b9350d0d114fa8db0e2f5bef6410139:/src/msw/button.cpp?ds=sidebyside diff --git a/src/msw/button.cpp b/src/msw/button.cpp index e512e506d2..08361d58b6 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -197,6 +197,11 @@ bool wxButton::Create(wxWindow *parent, wxButton::~wxButton() { + wxWindow *parent = GetParent(); + if ( parent && parent->GetTmpDefaultItem() == this ) + { + UnsetTmpDefault(); + } } // ---------------------------------------------------------------------------- @@ -397,18 +402,13 @@ wxButton::SetDefaultStyle(wxButton *btn, bool on) if ( !wxTheApp->IsActive() ) return; - // look for a panel-like window - wxWindow *win = btn->GetParent(); - while ( win && !win->HasFlag(wxTAB_TRAVERSAL) ) - win = win->GetParent(); + wxWindow * const parent = btn->GetParent(); + wxCHECK_RET( parent, _T("button without parent?") ); - if ( win ) - { - ::SendMessage(GetHwndOf(win), DM_SETDEFID, btn->GetId(), 0L); + ::SendMessage(GetHwndOf(parent), DM_SETDEFID, btn->GetId(), 0L); - // sending DM_SETDEFID also changes the button style to - // BS_DEFPUSHBUTTON so there is nothing more to do - } + // sending DM_SETDEFID also changes the button style to + // BS_DEFPUSHBUTTON so there is nothing more to do } // then also change the style as needed