1

I have a case where I want the menus to set the check on items using ON_UPDATE_COMMAND_UI; however, on the toolbar I'm going to use a dropdown toolbar, so I only want to select the correct toolbar item and not change its checked state.

How do I determine if the ON_UPDATE_COMMAND_UI call is for the menu-bar or the toolbar?

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
user3161924
  • 1,849
  • 18
  • 33
  • Use different command IDs for the menu vs. the toolbar button, since it doesn't sound like they implement the same behaviors anyway. – dxiv Feb 27 '21 at 05:38
  • The idea was a multiple option choice that could be selected via a drop down toolbar, but clicking on it really doesn't do anything (just a visual of the current option) , i may rethink what to do for the toolbar. – user3161924 Feb 27 '21 at 05:46

1 Answers1

2

You can check the m_pMenu member of the handler's given CCmdUI parameter; if the routine was invoked for a menu item, that will be a valid CMenu* pointer; if not, it will be NULL:

void CMyClass::OnUpdateHandler(CCmdUI *pCmdUI)
{
   if (!pCmdUI->m_pMenu) {
       // NOT for a menu
   }
   else {
       // For a menu
   }
}
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83