+ return true;
+}
+
+bool wxSpinCtrl::Reparent(wxWindowBase *newParent)
+{
+ // Reparenting both the updown control and its buddy does not seem to work:
+ // they continue to be connected somehow, but visually there is no feedback
+ // on the buddy edit control. To avoid this problem, we reparent the buddy
+ // window normally, but we recreate the updown control and reassign its
+ // buddy.
+
+ // Get the position before changing the parent as it would be offset after
+ // changing it.
+ const wxRect rect = GetRect();
+
+ if ( !wxWindowBase::Reparent(newParent) )
+ return false;
+
+ newParent->GetChildren().DeleteObject(this);
+
+ // destroy the old spin button after detaching it from this wxWindow object
+ // (notice that m_hWnd will be reset by UnsubclassWin() so save it first)
+ const HWND hwndOld = GetHwnd();
+ UnsubclassWin();
+ if ( !::DestroyWindow(hwndOld) )
+ {
+ wxLogLastError(wxT("DestroyWindow"));
+ }
+
+ // create and initialize the new one
+ if ( !wxSpinButton::Create(GetParent(), GetId(),
+ rect.GetPosition(), rect.GetSize(),
+ GetWindowStyle(), GetName()) )
+ return false;
+
+ // reapply our values to wxSpinButton
+ wxSpinButton::SetValue(GetValue());
+ SetRange(m_min, m_max);
+
+ // also set the size again with wxSIZE_ALLOW_MINUS_ONE flag: this is
+ // necessary if our original position used -1 for either x or y
+ SetSize(rect, wxSIZE_ALLOW_MINUS_ONE);
+
+ // associate it with the buddy control again
+ ::SetParent(GetBuddyHwnd(), GetHwndOf(GetParent()));
+ (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)GetBuddyHwnd(), 0);
+
+ return true;