+ wxWindow* pParent = GetParent();
+
+ wxCHECK_RET( pParent, _T("button without parent?") );
+
+ //
+ // Set this one as the default button both for wxWindows and Windows
+ //
+ wxWindow* pWinOldDefault = pParent->SetDefaultItem(this);
+ UpdateDefaultStyle( this
+ ,pWinOldDefault
+ );
+} // end of wxButton::SetDefault
+
+void wxButton::SetTmpDefault()
+{
+ wxWindow* pParent = GetParent();
+
+ wxCHECK_RET( pParent, _T("button without parent?") );
+
+ wxWindow* pWinOldDefault = pParent->GetDefaultItem();
+ pParent->SetTmpDefaultItem(this);
+ if (pWinOldDefault != this)
+ {
+ UpdateDefaultStyle( this
+ ,pWinOldDefault
+ );
+ }
+ //else: no styles to update
+} // end of wxButton::SetTmpDefault
+
+void wxButton::UnsetTmpDefault()
+{
+ wxWindow* pParent = GetParent();
+
+ wxCHECK_RET( pParent, _T("button without parent?") );
+
+ pParent->SetTmpDefaultItem(NULL);
+
+ wxWindow* pWinOldDefault = pParent->GetDefaultItem();
+
+ if (pWinOldDefault != this)
+ {
+ UpdateDefaultStyle( pWinOldDefault
+ ,this
+ );
+ }
+ //else: we had been default before anyhow
+} // end of wxButton::UnsetTmpDefault
+
+void wxButton::UpdateDefaultStyle(
+ wxWindow* pWinDefault
+, wxWindow* pWinOldDefault)
+{
+ wxButton* pBtnOldDefault = wxDynamicCast(pWinOldDefault, wxButton);
+ long lStyle;
+
+ if ( pBtnOldDefault && pBtnOldDefault != pWinDefault )
+ {
+ lStyle = ::WinQueryWindowULong(GetHwndOf(pBtnOldDefault), QWL_STYLE);
+ if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
+ {
+ lStyle &= ~BS_DEFAULT;
+ ::WinSetWindowULong(GetHwndOf(pBtnOldDefault), QWL_STYLE, lStyle);
+ }
+ else
+ {
+ // redraw the button - it will notice itself that it's not the
+ // default one any longer
+ pBtnOldDefault->Refresh();
+ }
+ }
+
+ wxButton* pBtnDefault = wxDynamicCast(pWinDefault, wxButton);