Thread: Disabling File->open in main frame of an MDI

  1. #1
    Registered User
    Join Date
    Dec 2004

    Disabling File->open in main frame of an MDI

    I have been trying to disable File->open in main frame of an MDI application that I made using the MSVS .NET wizard.
    I tried EnableMenuItem(..) but I don't know how to get an HMENU for the menus created by the wizard. Any help would be highly appreciated.

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    Find the menu item in the 'resouce view'. Add an event handler that does not call the default handler for the item (remove the call and return true).


    Look at the 'Resource View' window and find the main menu, set items property to disabled.


    As above but find menu items ID (ID_FILE_OPEN = file open in IDR_MAINFRAME main MFC created menu)

    then, with error checking added to code.
    //get the main window
    CWnd* pMain = AfxGetMainWnd();
    //find menu
    CMenu* pMenu = pMain->GetMenu();
    //you may have to get the sub menu here (not 100% sure)
    CMenu* pSubMenu = pMenu->GetSubMenu(0); //left most sub menu
    //disable item
    pSubMenu->EnableMenuItem( ID_FILE_OPEN ,MF_BYCOMMAND|MF_GRAYED); //default MFC file open ID#
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Animation not working....
    By aquinn in forum C Programming
    Replies: 7
    Last Post: 02-19-2005, 05:37 AM