+#if wxUSE_UXTHEME
+ // If we want the default themed border then we need to draw it ourselves
+ case WM_NCCALCSIZE:
+ {
+ wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
+ const wxBorder border = TranslateBorder(GetBorder());
+ if (theme && border == wxBORDER_THEME)
+ {
+ // first ask the widget to calculate the border size
+ rc.result = MSWDefWindowProc(message, wParam, lParam);
+ processed = true;
+
+ // now alter the client size making room for drawing a themed border
+ NCCALCSIZE_PARAMS *csparam = NULL;
+ RECT rect;
+ if (wParam)
+ {
+ csparam = (NCCALCSIZE_PARAMS*)lParam;
+ rect = csparam->rgrc[0];
+ }
+ else
+ {
+ rect = *((RECT*)lParam);
+ }
+ wxUxThemeHandle hTheme((wxWindow *)this, L"EDIT");
+ RECT rcClient = { 0, 0, 0, 0 };
+ wxClientDC dc((wxWindow *)this);
+
+ if (theme->GetThemeBackgroundContentRect(
+ hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL,
+ &rect, &rcClient) == S_OK)
+ {
+ InflateRect(&rcClient, -1, -1);
+ if (wParam)
+ csparam->rgrc[0] = rcClient;
+ else
+ *((RECT*)lParam) = rcClient;
+ rc.result = WVR_REDRAW;
+ }
+ }
+ }
+ break;
+
+ case WM_NCPAINT:
+ {
+ wxUxThemeEngine* theme = wxUxThemeEngine::GetIfActive();
+ const wxBorder border = TranslateBorder(GetBorder());
+ if (theme && border == wxBORDER_THEME)
+ {
+ // first ask the widget to paint its non-client area, such as scrollbars, etc.
+ rc.result = MSWDefWindowProc(message, wParam, lParam);
+ processed = true;
+
+ wxUxThemeHandle hTheme((wxWindow *)this, L"EDIT");
+ wxWindowDC dc((wxWindow *)this);
+
+ // Clip the DC so that you only draw on the non-client area
+ RECT rcBorder;
+ wxCopyRectToRECT(GetSize(), rcBorder);
+
+ RECT rcClient;
+ theme->GetThemeBackgroundContentRect(
+ hTheme, GetHdcOf(dc), EP_EDITTEXT, ETS_NORMAL, &rcBorder, &rcClient);
+ InflateRect(&rcClient, -1, -1);
+
+ ::ExcludeClipRect(GetHdcOf(dc), rcClient.left, rcClient.top,
+ rcClient.right, rcClient.bottom);
+
+ // Make sure the background is in a proper state
+ if (theme->IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
+ {
+ theme->DrawThemeParentBackground(GetHwnd(), GetHdcOf(dc), &rcBorder);
+ }
+
+ // Draw the border
+ int nState;
+ if ( !IsEnabled() )
+ nState = ETS_DISABLED;
+ // should we check this?
+ //else if ( ::GetWindowLong(GetHwnd(), GWL_STYLE) & ES_READONLY)
+ // nState = ETS_READONLY;
+ else
+ nState = ETS_NORMAL;
+ theme->DrawThemeBackground(hTheme, GetHdcOf(dc), EP_EDITTEXT, nState, &rcBorder, NULL);
+ }
+ }
+ break;
+
+#endif // wxUSE_UXTHEME
+