Reputation: 2309
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?
Upvotes: 1
Views: 383
Reputation: 51825
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
}
}
Upvotes: 2