Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Enabling/Disabling Menu Items

Enabling/Disabling Menu Items

Scheduled Pinned Locked Moved C / C++ / MFC
csharparchitecturehelpquestionlearning
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mdurfee
    wrote on last edited by
    #1

    I've used the app wizard (.NET) to create a basic single view app, w/o doc-view architecture. I've added a few things to the file menu using the resource editor (new, load, save, etc..) and added message handlers to the main frame using the wizard. I have no problem checking any of the menu items using "GetMenu()->CheckMenuItem()" but i can't seem to disable any of the menu items "GetMenu()->EnableMenuItem()" I have tried using the sub-menu, and the main menu, and I have tried BYCOMMAND and BYPOSITION but I can't get it to work. I also can't get it to default as disabled using the resource editor. Is there something I'm forgetting? I'd appreciate any suggestions or comments.

    M M 2 Replies Last reply
    0
    • M mdurfee

      I've used the app wizard (.NET) to create a basic single view app, w/o doc-view architecture. I've added a few things to the file menu using the resource editor (new, load, save, etc..) and added message handlers to the main frame using the wizard. I have no problem checking any of the menu items using "GetMenu()->CheckMenuItem()" but i can't seem to disable any of the menu items "GetMenu()->EnableMenuItem()" I have tried using the sub-menu, and the main menu, and I have tried BYCOMMAND and BYPOSITION but I can't get it to work. I also can't get it to default as disabled using the resource editor. Is there something I'm forgetting? I'd appreciate any suggestions or comments.

      M Offline
      M Offline
      Mike Danberg
      wrote on last edited by
      #2

      You should add OnUpdate commands to the message map. For example if you have a menu item titled "New" that has OnNew(). You'd have OnUpdateNew(CCmdUI *pCmdUI) { pCmdUI->Enable(FALSE); // disables menu item } Thats the easiest way to do it. Never tried it with GetMenu() so I can't help with that.

      1 Reply Last reply
      0
      • M mdurfee

        I've used the app wizard (.NET) to create a basic single view app, w/o doc-view architecture. I've added a few things to the file menu using the resource editor (new, load, save, etc..) and added message handlers to the main frame using the wizard. I have no problem checking any of the menu items using "GetMenu()->CheckMenuItem()" but i can't seem to disable any of the menu items "GetMenu()->EnableMenuItem()" I have tried using the sub-menu, and the main menu, and I have tried BYCOMMAND and BYPOSITION but I can't get it to work. I also can't get it to default as disabled using the resource editor. Is there something I'm forgetting? I'd appreciate any suggestions or comments.

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        Use the FAQ, Luke 7.1 In my MFC program, I'm trying to disable a menu item with EnableMenuItem(), but it doesn't have any effect on the menu. Why?[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber There is a saying in statistics that a million monkeys pounding on typewriters would eventually create a work of Shakespeare. Thanks to the Internet, we now know that this is not true.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups