+ if ( rgnDummySeps.IsOk() )
+ {
+ // exclude the area occupied by the controls and stretchable spaces
+ // from the update region to prevent the toolbar from drawing
+ // separators in it
+ if ( !::ValidateRgn(GetHwnd(), GetHrgnOf(rgnDummySeps)) )
+ {
+ wxLogLastError(wxT("ValidateRgn()"));
+ }
+ }
+
+ // still let the native control draw everything else normally but set up a
+ // hook to be able to process the next WM_ERASEBKGND sent to our parent
+ // because toolbar will ask it to erase its background from its WM_PAINT
+ // handler (when using TBSTYLE_TRANSPARENT which we do always use)
+ //
+ // installing hook is not completely trivial as all kinds of strange
+ // situations are possible: sometimes we can be called recursively from
+ // inside the native toolbar WM_PAINT handler so the hook might already be
+ // installed and sometimes the native toolbar might not send WM_ERASEBKGND
+ // to the parent at all for whatever reason, so deal with all these cases
+ wxWindow * const parent = GetParent();
+ const bool hadHook = parent->MSWHasEraseBgHook();
+ if ( !hadHook )
+ GetParent()->MSWSetEraseBgHook(this);
+
+ MSWDefWindowProc(WM_PAINT, wParam, lParam);
+
+ if ( !hadHook )
+ GetParent()->MSWSetEraseBgHook(NULL);
+
+
+ if ( rgnDummySeps.IsOk() )
+ {
+ // erase the dummy separators region ourselves now as nobody painted
+ // over them
+ WindowHDC hdc(GetHwnd());
+ ::SelectClipRgn(hdc, GetHrgnOf(rgnDummySeps));
+ MSWDoEraseBackground(hdc);
+ }
+
+ return true;
+}
+
+WXHBRUSH wxToolBar::MSWGetToolbarBgBrush()
+{
+ // we conservatively use a solid brush here but we could also use a themed
+ // brush by using DrawThemeBackground() to create a bitmap brush (it'd need
+ // to be invalidated whenever the toolbar is resized and, also, correctly
+ // aligned using SetBrushOrgEx() before each use -- there is code for doing
+ // this in wxNotebook already so it'd need to be refactored into wxWindow)
+ //
+ // however inasmuch as there is a default background for the toolbar at all
+ // (and this is not a trivial question as different applications use very
+ // different colours), it seems to be a solid one and using REBAR
+ // background brush as we used to do before doesn't look good at all under
+ // Windows 7 (and probably Vista too), so for now we just keep it simple
+ wxColour const
+ colBg = m_hasBgCol ? GetBackgroundColour()
+ : wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
+ wxBrush * const
+ brush = wxTheBrushList->FindOrCreateBrush(colBg);
+
+ return brush ? static_cast<WXHBRUSH>(brush->GetResourceHandle()) : 0;
+}
+
+WXHBRUSH wxToolBar::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child)
+{
+ WXHBRUSH hbr = wxToolBarBase::MSWGetBgBrushForChild(hDC, child);
+ if ( hbr )
+ return hbr;
+
+ // the base class version only returns a brush for erasing children
+ // background if we have a non-default background colour but as the toolbar
+ // doesn't erase its own background by default, we need to always do it for
+ // (semi-)transparent children
+ if ( child->GetParent() == this && child->HasTransparentBackground() )
+ return MSWGetToolbarBgBrush();
+
+ return 0;