From 3316192f0d8a79103271a48cf293a338ba817975 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 Sep 2009 12:23:28 +0000 Subject: [PATCH 1/1] Set correct foreground default in wxControl::DoMSWControlColor(). Instead of hard-coding GetSysColor(COLOR_WINDOWTEXT), use GetForegroundColour() which will call GetDefaultAttributes() to retrieve the default foreground appropriate for this control. This also allows to make the code simpler by calling SetTextColor() only once. See #1691. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61860 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/control.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/msw/control.cpp b/src/msw/control.cpp index cab5151e1c..e71efd8f1e 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -375,10 +375,6 @@ bool wxControl::MSWOnNotify(int idCtrl, WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) { HDC hdc = (HDC)pDC; - if ( m_hasFgCol ) - { - ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); - } WXHBRUSH hbr = 0; if ( !colBg.Ok() ) @@ -402,12 +398,14 @@ WXHBRUSH wxControl::DoMSWControlColor(WXHDC pDC, wxColour colBg, WXHWND hWnd) hbr = (WXHBRUSH)brush->GetResourceHandle(); } - // if we use custom background, we should set foreground ourselves too - if ( hbr && !m_hasFgCol ) + // always set the foreground colour if we changed the background, whether + // m_hasFgCol is true or not: if it true, we must do it, of course, but + // even if it isn't, we must set the default foreground explicitly as by + // default just the simple black is used + if ( hbr ) { - ::SetTextColor(hdc, ::GetSysColor(COLOR_WINDOWTEXT)); + ::SetTextColor(hdc, wxColourToRGB(GetForegroundColour())); } - //else: already set above return hbr; } -- 2.45.2