+// 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)
+{
+ wxColour bgCol = GetBackgroundColour();
+ if (!bgCol.Ok())
+ {
+ event.Skip();
+ return;
+ }
+
+ // 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
+
+ RECT rect;
+ ::GetClientRect(GetHwnd(), &rect);
+
+ HBRUSH hBrush = ::CreateSolidBrush(wxColourToRGB(bgCol));
+
+ HDC hdc = GetHdcOf((*event.GetDC()));
+
+#ifndef __WXWINCE__
+ int mode = ::SetMapMode(hdc, MM_TEXT);
+#endif
+
+ ::FillRect(hdc, &rect, hBrush);
+ ::DeleteObject(hBrush);
+
+#ifndef __WXWINCE__
+ ::SetMapMode(hdc, mode);
+#endif
+}
+