Disabling File->open in main frame of an MDI

This is a discussion on Disabling File->open in main frame of an MDI within the Windows Programming forums, part of the Platform Specific Boards category; I have been trying to disable File->open in main frame of an MDI application that I made using the MSVS ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    205

    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.
    Amish

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    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).

    or

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

    or

    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.
    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, 01:53 AM
  5. Animation not working....
    By aquinn in forum C Programming
    Replies: 7
    Last Post: 02-19-2005, 04:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21