void CCmdUI::Enable(BOOL bOn)
{
if (m_pMenu != NULL)
{
if (m_pSubMenu != NULL)
return; // don't change popup menus indirectly
ASSERT(m_nIndex < m_nIndexMax);
m_pMenu->EnableMenuItem(m_nIndex, MF_BYPOSITION |
(bOn ? MF_ENABLED : (MF_DISABLED | MF_GRAYED)));
}
else
{
// enable/disable a control (i.e. child window)
ASSERT(m_pOther != NULL);
// if control has the focus, move the focus before disabling
if (!bOn && (::GetFocus() == m_pOther->m_hWnd))
m_pOther->GetParent()->GetNextDlgTabItem(m_pOther)->SetFocus();
m_pOther->EnableWindow(bOn);
}
m_bEnableChanged = TRUE;
}
你可以设置一个标志,在更新函数中检测标志再决定是否enable
好久不写mfc细节记不得了
在窗口类里加成员变量m_flag,在菜单A响应函数里面m_flag = fase;
然后在菜单B的on-update-ui响应函数里面写if(m_flag) cmdUI->enable(TRUE)...
有函数,分析下CMenu类
GetDlgItem(菜单ID)->Enable=false