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.
This commit is contained in:
Artur Wieczorek 2016-01-25 22:27:05 +01:00 committed by Vadim Zeitlin
parent fadda15db1
commit 68eae6ba5b

View File

@ -1597,12 +1597,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<wxToolBarTool*>(tool);
tbTool->GetControl()->Enable(enable);
wxStaticText* text = tbTool->GetStaticText();
if ( text )
text->Enable(enable);
}
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *tool,