+void wxWindowMSW::OnEraseBackground(wxEraseEvent& event)
+{
+ if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM )
+ {
+ // don't skip the event here, custom background means that the app is
+ // drawing it itself in its OnPaint()
+ return;
+ }
+
+ if ( !m_hasBgCol )
+ {
+ event.Skip();
+ return;
+ }
+
+ // we have a fixed solid background colour, do use it
+ RECT rect;
+ ::GetClientRect(GetHwnd(), &rect);
+
+ wxColour backgroundColour(GetBackgroundColour());
+ COLORREF ref = PALETTERGB(backgroundColour.Red(),
+ backgroundColour.Green(),
+ backgroundColour.Blue());
+ HBRUSH hBrush = ::CreateSolidBrush(ref);
+ if ( !hBrush )
+ wxLogLastError(wxT("CreateSolidBrush"));
+
+ HDC hdc = (HDC)event.GetDC()->GetHDC();
+
+#ifndef __WXWINCE__
+ int mode = ::SetMapMode(hdc, MM_TEXT);
+#endif
+
+ ::FillRect(hdc, &rect, hBrush);
+ ::DeleteObject(hBrush);
+
+#ifndef __WXWINCE__
+ ::SetMapMode(hdc, mode);
+#endif
+}
+