From 79176c652aa2087d81b6f783adc7ead54fc42255 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 4 Sep 2007 06:59:50 +0000 Subject: [PATCH] Apply the background fix only if the toolbar has controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48549 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/tbar95.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 4ed908d923..f6de304212 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -308,15 +308,6 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size) ::SendMessage(GetHwnd(), TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS); #endif - // The toolbar background for some colour schemes cannot be determined - // (for example Silver). So set an explicit background colour to avoid parts of - // the background being painted wrongly. - - int majorVersion, minorVersion; - wxGetOsVersion(& majorVersion, & minorVersion); - if (majorVersion < 6) - SetBackgroundColour(GetBackgroundColour()); - return true; } @@ -1009,6 +1000,8 @@ bool wxToolBar::Realize() // Deal with the controls finally // ------------------------------ + bool hasControls = false; + // adjust the controls size to fit nicely in the toolbar int y = 0; size_t index = 0; @@ -1040,6 +1033,8 @@ bool wxToolBar::Realize() continue; } + hasControls = true; + wxControl *control = tool->GetControl(); wxStaticText * const staticText = tool->GetStaticText(); @@ -1180,6 +1175,13 @@ bool wxToolBar::Realize() InvalidateBestSize(); UpdateSize(); + // Fix a bug on e.g. the Silver theme on WinXP where control backgrounds + // are incorrectly drawn, by forcing the background to a specific colour. + int majorVersion, minorVersion; + wxGetOsVersion(& majorVersion, & minorVersion); + if (majorVersion < 6 && hasControls && !!UseBgCol()) + SetBackgroundColour(GetBackgroundColour()); + return true; } -- 2.47.2