Removing top level Menu item (in MFC). .

303 Views Asked by At

1> I could remove top level menu item (along with its sub-menus) in MFC MDI application using below code.

void CMainFrame::OnRemoveMyMenu()
{
    ////////////////////////////////////////////////////////////////////////
    CString sMenuText = _T("");
    BOOL bReturn = FALSE;

    const CMFCMenuBar *pMenuBar = GetMenuBar();

    HMENU hMainMenu = NULL;
    HMENU hSubMenu = NULL;

    hMainMenu = pMenuBar->GetHMenu();
    ASSERT(hMainMenu);

    RemoveMenu(hMainMenu, 3, MF_BYPOSITION);
    //----------------------------------------------------------------------
}

2> However, it works only on AppWizard created IDR_MAINFRAME menu. It does "not" work on another menu created in Resources by AppWizard, mainly IDR_<>TYPE menu (which is the Menu displayed with MDI window is put on).

3> I tried to call similar code within different places in View as well as call the same code as above, placed in MainFrame from View. But it did not work.

4> Can somebody given hint as to what I am missing?

Thanks a lot

KA.Mumbai

0

There are 0 best solutions below