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. Change the property of a menu

Change the property of a menu

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelptutorialquestion
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.
  • H Offline
    H Offline
    houari_id
    wrote on last edited by
    #1

    I am new in Visual C++. I created MDI application, and I want to disable some menu for certain function. For example, I want to disable menu with ID_MENU00 ID, when doDisableMenu() is invoked void doDisableMenu() { CMenu menu; menu.EnableMenuItem(ID_MENU00, MF_GRAYED); } but the result is an error of 'debug assertion failed' what should I do to disable a menu? thank you in advance

    C D 2 Replies Last reply
    0
    • H houari_id

      I am new in Visual C++. I created MDI application, and I want to disable some menu for certain function. For example, I want to disable menu with ID_MENU00 ID, when doDisableMenu() is invoked void doDisableMenu() { CMenu menu; menu.EnableMenuItem(ID_MENU00, MF_GRAYED); } but the result is an error of 'debug assertion failed' what should I do to disable a menu? thank you in advance

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      It doesn't work that way. When you have a menu item selected in the IDE, there are two messages you can catch. One is the click event, the other is called just before a menu item is shown. You keep a bool in your app to tell you if a menu item is disabled, and in that method, you take the menu item ( which is passed in from memory, as a pointer ), and you set if it's enabled or not using that boolean value. The same goes for check marks, etc. Any change to a menu items state happens in this event handler. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • H houari_id

        I am new in Visual C++. I created MDI application, and I want to disable some menu for certain function. For example, I want to disable menu with ID_MENU00 ID, when doDisableMenu() is invoked void doDisableMenu() { CMenu menu; menu.EnableMenuItem(ID_MENU00, MF_GRAYED); } but the result is an error of 'debug assertion failed' what should I do to disable a menu? thank you in advance

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        houari_id wrote: I want to disable some menu for certain function The preferred method for this is in the ON_UPDATE_COMMAND_UI() handler.


        "Ideas are a dime a dozen. People who put them into action are priceless." - Unknown

        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