kaixuan1115 / notes

笔记收录
6 stars 0 forks source link

对话框添加 ON_UPDATE_COMMAND_UI 更新菜单和工具栏 #10

Closed xiaokaixuan closed 5 years ago

xiaokaixuan commented 5 years ago
BOOL CTestDlg::ContinueModal()
{
    if (m_toolBar.IsWindowVisible())
    {
        m_toolBar.OnUpdateCmdUI((CFrameWnd*)this, TRUE);
    }
    CCmdUI cmdUI;
    cmdUI.m_pParentMenu = GetMenu();
    if (NULL != cmdUI.m_pParentMenu)
    {
        for (UINT ui(0); ui < cmdUI.m_pParentMenu->GetMenuItemCount()
        ; ++ui)
        {
            cmdUI.m_pMenu = cmdUI.m_pParentMenu->GetSubMenu(ui);
            cmdUI.m_nIndexMax = cmdUI.m_pMenu->GetMenuItemCount();
            for (UINT uIndex(0); uIndex < cmdUI.m_nIndexMax; ++uIndex)
            {
                cmdUI.m_nID = cmdUI.m_pMenu->GetMenuItemID(uIndex);
                cmdUI.m_nIndex = uIndex;
                cmdUI.DoUpdate(this, TRUE);
            }
        }
    }
    return CDialog::ContinueModal(); 
}