-// This handler is required to allow the toolbar to be set to a non-default
-// colour: for example, when it must blend in with a notebook page.
-void wxToolBar::OnEraseBackground(wxEraseEvent& event)
-{
- RECT rect = wxGetClientRect(GetHwnd());
-
- wxDC *dc = event.GetDC();
- HDC hdc = GetHdcOf(*dc);
-
-#if wxUSE_UXTHEME
- // we may need to draw themed colour so that we appear correctly on
- // e.g. notebook page under XP with themes but only do it if the parent
- // draws themed background itself
- if ( !UseBgCol() && !GetParent()->UseBgCol() )
- {
- wxUxThemeEngine *theme = wxUxThemeEngine::GetIfActive();
- if ( theme )
- {
- HRESULT
- hr = theme->DrawThemeParentBackground(GetHwnd(), hdc, &rect);
- if ( hr == S_OK )
- return;
-
- // it can also return S_FALSE which seems to simply say that it
- // didn't draw anything but no error really occurred
- if ( FAILED(hr) )
- {
- wxLogApiError(wxT("DrawThemeParentBackground(toolbar)"), hr);
- }
- }
- }
-
- if ( MSWEraseRect(*dc) )
- return;
-#endif // wxUSE_UXTHEME
-
- // we need to always draw our background under XP, as otherwise it doesn't
- // appear correctly with some themes (e.g. Zune one)
- if ( wxGetWinVersion() == wxWinVersion_XP ||
- UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT) )
- {
- // do draw our background
- //
- // notice that this 'dumb' implementation may cause flicker for some of
- // the controls in which case they should intercept wxEraseEvent and
- // process it themselves somehow
- AutoHBRUSH hBrush(wxColourToRGB(GetBackgroundColour()));
-
- wxCHANGE_HDC_MAP_MODE(hdc, MM_TEXT);
- ::FillRect(hdc, &rect, hBrush);
- }
- else // we have no non-default background colour
- {
- // let the system do it for us
- event.Skip();
- }
-}
-