c++buttonmfcpanecmfctoolbar

Enabling\disabling CMFCToolBar buttons when embedded in pane


I know the best way to enable/disable a button from CMFCToolBar is to use

  int b_id = m_ToolBar.CommandToIndex(ID_BUTTON);
    m_ToolBar.SetButtonStyle(b_id,TBBS_DISABLED);

but that does not seem to work when the toolbar is embedded inside a CDockable Pane I have a derived class for CMFCToolBar which is required to enable the buttons in a pane but nothing I have tried will disable them.


Solution

  • OK I found the only solution was not to use the standard methods of disabling the buttons but to put the conditions in each of the on command update functions and use pCmdUI->Enable(FALSE); not much unlike what you would do to menus.