+
+bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
+{
+    DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item;
+
+    if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON )
+        return wxCheckBoxBase::MSWOnDraw(item);
+
+    // calculate the rectangles for the check mark itself and the label
+    HDC hdc = dis->hDC;
+    RECT& rect = dis->rcItem;
+    RECT rectCheck,
+         rectLabel;
+    rectCheck.top =
+    rectLabel.top = rect.top;
+    rectCheck.bottom =
+    rectLabel.bottom = rect.bottom;
+    const int checkSize = GetBestSize().y;
+    const int MARGIN = 3;
+
+    const bool isRightAligned = HasFlag(wxALIGN_RIGHT);
+    if ( isRightAligned )
+    {
+        rectCheck.right = rect.right;
+        rectCheck.left = rectCheck.right - checkSize;
+
+        rectLabel.right = rectCheck.left - MARGIN;
+        rectLabel.left = rect.left;
+    }
+    else // normal, left-aligned checkbox
+    {
+        rectCheck.left = rect.left;
+        rectCheck.right = rectCheck.left + checkSize;
+
+        rectLabel.left = rectCheck.right + MARGIN;
+        rectLabel.right = rect.right;
+    }
+
+    // show we draw a focus rect?
+    const bool isFocused = m_isPressed || FindFocus() == this;
+
+
+    // draw the checkbox itself: note that this should really, really be in
+    // wxRendererNative but unfortunately we can't add a new virtual function
+    // to it without breaking backwards compatibility
+
+    // classic Win32 version -- this can be useful when we move this into
+    // wxRendererNative
+#if defined(__WXWINCE__) || !wxUSE_UXTHEME
+    UINT state = DFCS_BUTTONCHECK;
+    if ( !IsEnabled() )
+        state |= DFCS_INACTIVE;
+    switch ( Get3StateValue() )
+    {
+        case wxCHK_CHECKED:
+            state |= DFCS_CHECKED;
+            break;
+
+        case wxCHK_UNDETERMINED:
+            state |= DFCS_PUSHED;
+            break;
+
+        default:
+            wxFAIL_MSG( _T("unexpected Get3StateValue() return value") );
+            // fall through
+
+        case wxCHK_UNCHECKED:
+            // no extra styles needed
+            break;
+    }
+
+    if ( wxFindWindowAtPoint(wxGetMousePosition()) == this )
+        state |= DFCS_HOT;
+
+    if ( !::DrawFrameControl(hdc, &rectCheck, DFC_BUTTON, state) )
+    {
+        wxLogLastError(_T("DrawFrameControl(DFC_BUTTON)"));
+    }
+#else // XP version
+    wxUxThemeEngine *themeEngine = wxUxThemeEngine::GetIfActive();
+    if ( !themeEngine )
+        return false;
+
+    wxUxThemeHandle theme(this, L"BUTTON");
+    if ( !theme )
+        return false;
+
+    int state;
+    switch ( Get3StateValue() )
+    {
+        case wxCHK_CHECKED:
+            state = CBS_CHECKEDNORMAL;
+            break;
+
+        case wxCHK_UNDETERMINED:
+            state = CBS_MIXEDNORMAL;
+            break;
+
+        default:
+            wxFAIL_MSG( _T("unexpected Get3StateValue() return value") );
+            // fall through
+
+        case wxCHK_UNCHECKED:
+            state = CBS_UNCHECKEDNORMAL;
+            break;
+    }
+
+    if ( !IsEnabled() )
+        state += CBS_DISABLED_OFFSET;
+    else if ( m_isPressed )
+        state += CBS_PRESSED_OFFSET;
+    else if ( m_isHot )
+        state += CBS_HOT_OFFSET;
+
+    HRESULT hr = themeEngine->DrawThemeBackground
+                              (
+                                theme,
+                                hdc,
+                                BP_CHECKBOX,
+                                state,
+                                &rectCheck,
+                                NULL
+                              );
+    if ( FAILED(hr) )
+    {
+        wxLogApiError(_T("DrawThemeBackground(BP_CHECKBOX)"), hr);
+    }
+#endif // 0/1
+
+    // draw the text
+    const wxString& label = GetLabel();
+
+    // first we need to measure it
+    UINT fmt = DT_NOCLIP;
+
+    // drawing underlying doesn't look well with focus rect (and the native
+    // control doesn't do it)
+    if ( isFocused )
+        fmt |= DT_HIDEPREFIX;
+    if ( isRightAligned )
+        fmt |= DT_RIGHT;
+    // TODO: also use DT_HIDEPREFIX if the system is configured so
+
+    // we need to get the label real size first if we have to draw a focus rect
+    // around it
+    if ( isFocused )
+    {
+        if ( !::DrawText(hdc, label, label.length(), &rectLabel,
+                         fmt | DT_CALCRECT) )
+        {
+            wxLogLastError(_T("DrawText(DT_CALCRECT)"));
+        }
+    }
+
+    if ( !IsEnabled() )
+    {
+        ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT));
+    }
+
+    if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt) )
+    {
+        wxLogLastError(_T("DrawText()"));
+    }
+
+    // finally draw the focus
+    if ( isFocused )
+    {
+        rectLabel.left--;
+        rectLabel.right++;
+        if ( !::DrawFocusRect(hdc, &rectLabel) )
+        {
+            wxLogLastError(_T("DrawFocusRect()"));
+        }
+    }
+
+    return true;
+}
+
+#endif // wxUSE_CHECKBOX