+ // Test for the custom background brush first.
+ WXHBRUSH hbrush = MSWGetCustomBgBrush();
+ if ( hbrush )
+ {
+ // We assume that this is either a stipple or hatched brush and not a
+ // solid one as otherwise it would have been enough to set the
+ // background colour and such brushes need to be positioned correctly
+ // in order to align when different windows are painted, so do it here.
+ RECT rc;
+ ::GetWindowRect(GetHwndOf(child), &rc);
+
+ ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1);
+
+ int x = rc.left,
+ y = rc.top;
+ MSWAdjustBrushOrg(&x, &y);
+
+ if ( !::SetBrushOrgEx((HDC)hDC, -x, -y, NULL) )
+ {
+ wxLogLastError(wxT("SetBrushOrgEx(bg brush)"));
+ }
+
+ return hbrush;
+ }
+
+ // Otherwise see if we have a custom background colour.