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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Disabling item in MENUBAR

Disabling item in MENUBAR

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 4 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.
  • K Offline
    K Offline
    Killer3
    wrote on last edited by
    #1

    Hi, CMenu* pMenu = GetMenu(); ASSERT (pMenu != NULL); for(int i=0;i< (int)pMenu->GetMenuItemCount();i++) { CMenu* pActionMenu = pMenu->GetSubMenu(i); ASSERT (pActionMenu != NULL); int nMenuItemCount = pActionMenu->GetMenuItemCount(); int nTemp = nMenuItemCount-1 ; nMenuItemCount=nMenuItemCount-1; while (nMenuItemCount >= 0) { if(!(i==0 && nMenuItemCount==nTemp)) { pActionMenu->RemoveMenu(nMenuItemCount, MF_BYPOSITION); //pActionMenu->EnableMenuItem( pActionMenu->GetMenuItemID (nMenuItemCount) ,MF_BYCOMMAND|MF_DISABLED); } nMenuItemCount=nMenuItemCount-1; } } Requirement : Disabling all menu items I have used the above code snippet to removing Menu items in my application. But when i attempt to use EnableMenuItem for disabling than removing it fails. Can any one show some light on this? for thendral

    A N 2 Replies Last reply
    0
    • K Killer3

      Hi, CMenu* pMenu = GetMenu(); ASSERT (pMenu != NULL); for(int i=0;i< (int)pMenu->GetMenuItemCount();i++) { CMenu* pActionMenu = pMenu->GetSubMenu(i); ASSERT (pActionMenu != NULL); int nMenuItemCount = pActionMenu->GetMenuItemCount(); int nTemp = nMenuItemCount-1 ; nMenuItemCount=nMenuItemCount-1; while (nMenuItemCount >= 0) { if(!(i==0 && nMenuItemCount==nTemp)) { pActionMenu->RemoveMenu(nMenuItemCount, MF_BYPOSITION); //pActionMenu->EnableMenuItem( pActionMenu->GetMenuItemID (nMenuItemCount) ,MF_BYCOMMAND|MF_DISABLED); } nMenuItemCount=nMenuItemCount-1; } } Requirement : Disabling all menu items I have used the above code snippet to removing Menu items in my application. But when i attempt to use EnableMenuItem for disabling than removing it fails. Can any one show some light on this? for thendral

      A Offline
      A Offline
      ashokbngr
      wrote on last edited by
      #2

      RemoveMenu: Deletes a menu item with an associated pop-up menu from the menu. Try using same function i.e EnableMenuItem for enabling & diabling the menu items. Regards, Ashok.

      1 Reply Last reply
      0
      • K Killer3

        Hi, CMenu* pMenu = GetMenu(); ASSERT (pMenu != NULL); for(int i=0;i< (int)pMenu->GetMenuItemCount();i++) { CMenu* pActionMenu = pMenu->GetSubMenu(i); ASSERT (pActionMenu != NULL); int nMenuItemCount = pActionMenu->GetMenuItemCount(); int nTemp = nMenuItemCount-1 ; nMenuItemCount=nMenuItemCount-1; while (nMenuItemCount >= 0) { if(!(i==0 && nMenuItemCount==nTemp)) { pActionMenu->RemoveMenu(nMenuItemCount, MF_BYPOSITION); //pActionMenu->EnableMenuItem( pActionMenu->GetMenuItemID (nMenuItemCount) ,MF_BYCOMMAND|MF_DISABLED); } nMenuItemCount=nMenuItemCount-1; } } Requirement : Disabling all menu items I have used the above code snippet to removing Menu items in my application. But when i attempt to use EnableMenuItem for disabling than removing it fails. Can any one show some light on this? for thendral

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        Use ON_UPDATE_COMMAND_UI.


        Nibu thomas Software Developer

        K 1 Reply Last reply
        0
        • N Nibu babu thomas

          Use ON_UPDATE_COMMAND_UI.


          Nibu thomas Software Developer

          K Offline
          K Offline
          Killer3
          wrote on last edited by
          #4

          I can use ON_UPDATE_COMMAND_UI if i need to disable a single menu item My requirement is to disable all menus in a single shot,How can this be done. Thanks for thendral

          stefanmihaimogaS N 2 Replies Last reply
          0
          • K Killer3

            I can use ON_UPDATE_COMMAND_UI if i need to disable a single menu item My requirement is to disable all menus in a single shot,How can this be done. Thanks for thendral

            stefanmihaimogaS Offline
            stefanmihaimogaS Offline
            stefanmihaimoga
            wrote on last edited by
            #5

            Hi, I think that the only solutions is to disable each item of your menu. There isn't other way to make this. Sorry and good coding!

            1 Reply Last reply
            0
            • K Killer3

              I can use ON_UPDATE_COMMAND_UI if i need to disable a single menu item My requirement is to disable all menus in a single shot,How can this be done. Thanks for thendral

              N Offline
              N Offline
              Nibu babu thomas
              wrote on last edited by
              #6

              You can use ON_UPDATE_COMMAND_UI_RANGE. There are certain limitations too.


              Nibu thomas Software Developer

              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