+            DrawRect(hdc, r);
+
+            ::InflateRect(&r, -1, -1);
+        }
+
+        wxDrawLine(hdc, r.left, r.bottom, r.right, r.bottom);
+        wxDrawLine(hdc, r.right, r.bottom, r.right, r.top - 1);
+
+        (void)SelectObject(hdc, hpenWhite);
+        wxDrawLine(hdc, r.left, r.bottom - 1, r.left, r.top);
+        wxDrawLine(hdc, r.left, r.top, r.right, r.top);
+
+        (void)SelectObject(hdc, hpenLightGr);
+        wxDrawLine(hdc, r.left + 1, r.bottom - 2, r.left + 1, r.top + 1);
+        wxDrawLine(hdc, r.left + 1, r.top + 1, r.right - 1, r.top + 1);
+
+        (void)SelectObject(hdc, hpenGrey);
+        wxDrawLine(hdc, r.left + 1, r.bottom - 1, r.right - 1, r.bottom - 1);
+        wxDrawLine(hdc, r.right - 1, r.bottom - 1, r.right - 1, r.top);
+    }
+
+    (void)SelectObject(hdc, hpenOld);
+    DeleteObject(hpenWhite);
+    DeleteObject(hpenLightGr);
+    DeleteObject(hpenGrey);
+    DeleteObject(hpenBlack);
+}
+
+#if wxUSE_UXTHEME
+static
+void MSWDrawXPBackground(wxButton *button, WXDRAWITEMSTRUCT *wxdis)
+{
+    LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis;
+    HDC hdc = lpDIS->hDC;
+    UINT state = lpDIS->itemState;
+    RECT rectBtn;
+    CopyRect(&rectBtn, &lpDIS->rcItem);
+
+    wxUxThemeHandle theme(button, L"BUTTON");
+    int iState;
+
+    if ( state & ODS_SELECTED )
+    {
+        iState = PBS_PRESSED;
+    }
+    else if ( button->HasCapture() || button->IsMouseInWindow() )
+    {
+        iState = PBS_HOT;
+    }
+    else if ( state & ODS_FOCUS )
+    {
+        iState = PBS_DEFAULTED;
+    }
+    else if ( state & ODS_DISABLED )
+    {
+        iState = PBS_DISABLED;
+    }
+    else
+    {
+        iState = PBS_NORMAL;
+    }
+
+    // draw parent background if needed
+    if ( wxUxThemeEngine::Get()->IsThemeBackgroundPartiallyTransparent(theme,
+                                                                       BP_PUSHBUTTON,
+                                                                       iState) )
+    {
+        wxUxThemeEngine::Get()->DrawThemeParentBackground(GetHwndOf(button), hdc, &rectBtn);
+    }
+
+    // draw background
+    wxUxThemeEngine::Get()->DrawThemeBackground(theme, hdc, BP_PUSHBUTTON, iState,
+                                                &rectBtn, NULL);
+
+    // calculate content area margins
+    MARGINS margins;
+    wxUxThemeEngine::Get()->GetThemeMargins(theme, hdc, BP_PUSHBUTTON, iState,
+                                            TMT_CONTENTMARGINS, &rectBtn, &margins);
+    RECT rectClient;
+    ::CopyRect(&rectClient, &rectBtn);
+    ::InflateRect(&rectClient, -margins.cxLeftWidth, -margins.cyTopHeight);
+
+    // if focused and !nofocus rect
+    if ( (state & ODS_FOCUS) && !(state & ODS_NOFOCUSRECT) )
+    {
+        DrawFocusRect(hdc, &rectClient);
+    }
+
+    if ( button->UseBgCol() )
+    {
+        COLORREF colBg = wxColourToRGB(button->GetBackgroundColour());
+        HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
+
+        // don't overwrite the focus rect
+        ::InflateRect(&rectClient, -1, -1);
+        FillRect(hdc, &rectClient, hbrushBackground);
+        ::DeleteObject(hbrushBackground);
+    }
+}
+#endif // wxUSE_UXTHEME
+
+bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
+{
+    LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)wxdis;
+    HDC hdc = lpDIS->hDC;
+    UINT state = lpDIS->itemState;
+    RECT rectBtn;
+    CopyRect(&rectBtn, &lpDIS->rcItem);
+
+#if wxUSE_UXTHEME
+    if ( wxUxThemeEngine::GetIfActive() )
+    {
+        MSWDrawXPBackground(this, wxdis);
+    }
+    else
+#endif // wxUSE_UXTHEME
+    {
+        COLORREF colBg = wxColourToRGB(GetBackgroundColour());
+
+        // first, draw the background
+        HBRUSH hbrushBackground = ::CreateSolidBrush(colBg);
+        FillRect(hdc, &rectBtn, hbrushBackground);
+        ::DeleteObject(hbrushBackground);
+
+        // draw the border for the current state
+        bool selected = (state & ODS_SELECTED) != 0;
+        if ( !selected )
+        {
+            wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+            if ( tlw )