From f82f74d09b81055e7d358d0328b7e590eb85cc01 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Mon, 25 Jan 2016 22:27:05 +0100 Subject: [PATCH] Fix disabling control tools in wxMSW wxToolBar Tools containing controls should be enabled/disabled in a different way from the button tools in wxToolBar::DoEnableTool(). The control and its label (if any) need to be explicitly enabled/disabled for wxToolBarBase::EnableTool() to work properly. Closes #17346. (cherry picked from commit 68eae6ba5b4040e9af61f9182b118d01f0ac47e8) --- src/msw/toolbar.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 97fffb4763..51a5f2422b 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1688,12 +1688,24 @@ void wxToolBar::SetWindowStyleFlag(long style) void wxToolBar::DoEnableTool(wxToolBarToolBase *tool, bool enable) { - ::SendMessage(GetHwnd(), TB_ENABLEBUTTON, - (WPARAM)tool->GetId(), (LPARAM)MAKELONG(enable, 0)); + if ( tool->IsButton() ) + { + ::SendMessage(GetHwnd(), TB_ENABLEBUTTON, + (WPARAM)tool->GetId(), (LPARAM)MAKELONG(enable, 0)); - // Adjust displayed checked state -- it could have changed if the tool is - // disabled and has a custom "disabled state" bitmap. - DoToggleTool(tool, tool->IsToggled()); + // Adjust displayed checked state -- it could have changed if the tool is + // disabled and has a custom "disabled state" bitmap. + DoToggleTool(tool, tool->IsToggled()); + } + else if ( tool->IsControl() ) + { + wxToolBarTool* tbTool = static_cast(tool); + + tbTool->GetControl()->Enable(enable); + wxStaticText* text = tbTool->GetStaticText(); + if ( text ) + text->Enable(enable); + } } void wxToolBar::DoToggleTool(wxToolBarToolBase *tool,