]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed parts of toolbar background not being drawn with older comctl32.dll.
authorDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Wed, 2 May 2012 14:44:45 +0000 (14:44 +0000)
committerDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Wed, 2 May 2012 14:44:45 +0000 (14:44 +0000)
When using comctl32.dll versions older than 6.0 toolbar icons would not have their background drawn. Fix this in a rough way by always completely erasing the background like was done before. Regression since r62971.

Closes #13512.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/toolbar.h
src/msw/toolbar.cpp

index fcfbec774be7b94a9fad4514c257ac9fd2ce86d1..bf02037ca3c22ad02d87f3a82655449843cbf495 100644 (file)
@@ -67,6 +67,7 @@ public:
 
     void OnMouseEvent(wxMouseEvent& event);
     void OnSysColourChanged(wxSysColourChangedEvent& event);
+    void OnEraseBackground(wxEraseEvent& event);
 
     void SetFocus() {}
 
index 4866b30c54c0c2b7f0e65010a8f7428915f91608..697b9c6c8d67fe8cfbd631109656f58be0287a84 100644 (file)
@@ -127,6 +127,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
 BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
     EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent)
     EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged)
+    EVT_ERASE_BACKGROUND(wxToolBar::OnEraseBackground)
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
@@ -340,7 +341,10 @@ bool wxToolBar::Create(wxWindow *parent,
     // in WM_ERASEBKGND too (by default this won't be done but if the toolbar
     // has a non default background colour, then it would be used in both
     // places resulting in flicker)
-    SetBackgroundStyle(wxBG_STYLE_PAINT);
+    if (wxApp::GetComCtl32Version() >= 600)
+    {
+        SetBackgroundStyle(wxBG_STYLE_PAINT);
+    }
 
     return true;
 }
@@ -1679,6 +1683,13 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event)
     }
 }
 
+// This handler is needed to fix problems with painting the background of
+// toolbar icons with comctl32.dll < 6.0.
+void wxToolBar::OnEraseBackground(wxEraseEvent& event)
+{
+    MSWDoEraseBackground(event.GetDC()->GetHDC());
+}
+
 bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
 {
     // wait until we have some tools