]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
don't erase background in wxControl neither
[wxWidgets.git] / src / msw / window.cpp
index 8c7b93ca6286f2ee435d5c3ab4b0d520198a848c..70f74831c8063ff4a9a0abfaa43c4a2971bfc0f8 100644 (file)
@@ -333,6 +333,7 @@ wxCONSTRUCTOR_DUMMY(wxWindow)
 
 BEGIN_EVENT_TABLE(wxWindowMSW, wxWindowBase)
     EVT_SYS_COLOUR_CHANGED(wxWindowMSW::OnSysColourChanged)
+    EVT_ERASE_BACKGROUND(wxWindowMSW::OnEraseBackground)
 #ifdef __WXWINCE__
     EVT_INIT_DIALOG(wxWindowMSW::OnInitDialog)
 #endif
@@ -4067,6 +4068,47 @@ bool wxWindowMSW::HandleEraseBkgnd(WXHDC hdc)
     return rc;
 }
 
+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
+}
+
 // ---------------------------------------------------------------------------
 // moving and resizing
 // ---------------------------------------------------------------------------