+ wxCHECK_RET( tlw, _T("button without top level window?") );
+
+ wxWindow* pWinOldDefault = tlw->GetDefaultItem();
+
+ tlw->SetTmpDefaultItem(this);
+ SetDefaultStyle( wxDynamicCast(pWinOldDefault, wxButton), false);
+ SetDefaultStyle( this, true );
+} // end of wxButton::SetTmpDefault
+
+void wxButton::UnsetTmpDefault()
+{
+ wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+
+ wxCHECK_RET( tlw, _T("button without top level window?") );
+
+ tlw->SetTmpDefaultItem(NULL);
+
+ wxWindow* pWinOldDefault = tlw->GetDefaultItem();
+
+ SetDefaultStyle( this, false );
+ SetDefaultStyle( wxDynamicCast(pWinOldDefault, wxButton), true );
+} // end of wxButton::UnsetTmpDefault
+
+void wxButton::SetDefaultStyle(
+ wxButton* pBtn
+, bool bOn
+)
+{
+ long lStyle;
+ //
+ // We may be called with NULL pointer -- simpler to do the check here than
+ // in the caller which does wxDynamicCast()
+ //
+ if (!pBtn)
+ return;
+
+ //
+ // First, let DefDlgProc() know about the new default button
+ //
+ if (bOn)
+ {
+ if (!wxTheApp->IsActive())
+ return;
+
+ //
+ // In OS/2 the dialog/panel doesn't really know it has a default
+ // button, the default button simply has that style. We'll just
+ // simulate by setting focus to it
+ //
+ pBtn->SetFocus();
+ }
+ lStyle = ::WinQueryWindowULong(GetHwndOf(pBtn), QWL_STYLE);
+ if (!(lStyle & BS_DEFAULT) == bOn)
+ {
+ if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
+ {
+ if (bOn)
+ lStyle |= BS_DEFAULT;
+ else
+ lStyle &= ~BS_DEFAULT;
+ ::WinSetWindowULong(GetHwndOf(pBtn), QWL_STYLE, lStyle);
+ }
+ else
+ {
+ //
+ // Redraw the button - it will notice itself that it's not the
+ // default one any longer
+ //
+ pBtn->Refresh();
+ }
+ }
+} // end of wxButton::UpdateDefaultStyle