我写了个基于对话框应用程序,我把一个菜单加入到对话框里面,
我想用SetCheck()设置选中方式,
可是有一般的方法好像不行啊
哪位帮一下

解决方案 »

  1.   

    对话框中如何对菜单相应ON_UPDATE_COMMAND_UI:
    msdn key : DLGCBR32 sample (MFC)
    关键步骤:
    void CxxxDlg::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
    {
    if (!bSysMenu)
    {
    ASSERT(pPopupMenu != NULL); // check the enabled state of various menu items
    CCmdUI state;
    state.m_pMenu = pPopupMenu;
    ASSERT(state.m_pOther == NULL); state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
    for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
     state.m_nIndex++)
    {
    state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
    if (state.m_nID == 0)
    continue; // menu separator or invalid cmd - ignore it ASSERT(state.m_pOther == NULL);
    ASSERT(state.m_pMenu != NULL);
    if (state.m_nID == (UINT)-1)
    {
    // possibly a popup menu, route to first item of that popup
    state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
    if (state.m_pSubMenu == NULL ||
    (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
    state.m_nID == (UINT)-1)
    {
    continue; // first item of popup can't be routed to
    }
    state.DoUpdate(this, FALSE);  // popups are never auto disabled
    }
    else
    {
    // normal menu item
    // Auto enable/disable if command is _not_ a system command
    state.m_pSubMenu = NULL;
    state.DoUpdate(this, state.m_nID < 0xF000);
    }
    }
    }
    }