]> git.saurik.com Git - wxWidgets.git/commitdiff
Restore correct setting of the background colour.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 12 Sep 2009 10:59:43 +0000 (10:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 12 Sep 2009 10:59:43 +0000 (10:59 +0000)
The background colour for the HDC used for drawing the native controls wasn't
set correctly any more after changes of r61859 but we do need to call it or
the text in edit and similar controls is drawn using the default background
even if we return the correct brush which is used for erasing the control.

Closes #11190.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/control.cpp

index e71efd8f1e9ba0d8383ba5928c2bc62b1aa38a77..46854f5c233864f5c6c9a6e90263731f4516919d 100644 (file)
@@ -388,12 +388,11 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
             colBg = GetBackgroundColour();
     }
 
-    // use the background colour override if a valid colour is given
+    // use the background colour override if a valid colour is given: this is
+    // used when the control is disabled to grey it out and also if colBg was
+    // set just above
     if ( colBg.Ok() )
     {
-        ::SetBkColor(hdc, wxColourToRGB(colBg));
-
-        // draw children with the same colour as the parent
         wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBg);
         hbr = (WXHBRUSH)brush->GetResourceHandle();
     }
@@ -407,6 +406,17 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd)
         ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
     }
 
+    // finally also set the background colour for text drawing: without this,
+    // the text in an edit control is drawn using the default background even
+    // if we return a valid brush
+    if ( colBg.IsOk() || m_hasBgCol )
+    {
+        if ( !colBg.IsOk() )
+            colBg = GetBackgroundColour();
+
+        ::SetBkColor(hdc, wxColourToRGB(colBg));
+    }
+
     return hbr;
 }