From: Vadim Zeitlin Date: Sat, 12 Sep 2009 10:59:43 +0000 (+0000) Subject: Restore correct setting of the background colour. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/db5a2bff58b2dadd6c657afa57e0e723b9cab71d Restore correct setting of the background colour. 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 --- diff --git a/src/msw/control.cpp b/src/msw/control.cpp index e71efd8f1e..46854f5c23 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -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; }