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. hide submenu item on selecting a menu item

hide submenu item on selecting a menu item

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 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.
  • S Offline
    S Offline
    Sunshine Always
    wrote on last edited by
    #1

    hi how do i disable a submenu item when i select another submenu item? thanks

    K T 3 Replies Last reply
    0
    • S Sunshine Always

      hi how do i disable a submenu item when i select another submenu item? thanks

      K Offline
      K Offline
      kasturi_haribabu
      wrote on last edited by
      #2

      SEE the Sample code.............. :) Please modify the code as per your project. CMenu *mnuPop; mnuPop->LoadMenu(IDR_TASKBAR_MENU); SetForegroundWindow(); CWnd* pWnd = AfxGetMainWnd(); if(pWnd->IsIconic() != 0) // minimized { mnuPop->GetSubMenu(0)->EnableMenuItem(ID_WJRU_WJRU,MF_BYPOSITION | MF_ENABLED); } else { mnuPop->GetSubMenu(0)->EnableMenuItem(ID_WJRU_WJRU, MF_BYPOSITION | MF_GRAYED); }

      S 1 Reply Last reply
      0
      • K kasturi_haribabu

        SEE the Sample code.............. :) Please modify the code as per your project. CMenu *mnuPop; mnuPop->LoadMenu(IDR_TASKBAR_MENU); SetForegroundWindow(); CWnd* pWnd = AfxGetMainWnd(); if(pWnd->IsIconic() != 0) // minimized { mnuPop->GetSubMenu(0)->EnableMenuItem(ID_WJRU_WJRU,MF_BYPOSITION | MF_ENABLED); } else { mnuPop->GetSubMenu(0)->EnableMenuItem(ID_WJRU_WJRU, MF_BYPOSITION | MF_GRAYED); }

        S Offline
        S Offline
        Sunshine Always
        wrote on last edited by
        #3

        thanks for the help. but i am actually writing for a menu bar and when i click on a submenu item another submenuitem should get disabled. hope u're getting what i am trying to do.

        1 Reply Last reply
        0
        • S Sunshine Always

          hi how do i disable a submenu item when i select another submenu item? thanks

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

          May be this will help you.. //This Code is Written in sub - submenu // Your First Menu. CMenu *mnuPop; // Your Second Menu. CMenu *mnuSubMenu; // Load your menu here... mnuPop->LoadMenu(IDR_THERMATYPE); // Get the Sub Menu handle handle here... mnuSubMenu = mnuPop->GetSubMenu(0); // Disable the Another Submenu from this Sub Menu... mnuSubMenu->EnableMenuItem(ID_EDIT_COPY,MF_BYPOSITION | MF_GRAYED); // Redraw your Menu after this.(only some times needed...

          S 1 Reply Last reply
          0
          • K kasturi_haribabu

            May be this will help you.. //This Code is Written in sub - submenu // Your First Menu. CMenu *mnuPop; // Your Second Menu. CMenu *mnuSubMenu; // Load your menu here... mnuPop->LoadMenu(IDR_THERMATYPE); // Get the Sub Menu handle handle here... mnuSubMenu = mnuPop->GetSubMenu(0); // Disable the Another Submenu from this Sub Menu... mnuSubMenu->EnableMenuItem(ID_EDIT_COPY,MF_BYPOSITION | MF_GRAYED); // Redraw your Menu after this.(only some times needed...

            S Offline
            S Offline
            Sunshine Always
            wrote on last edited by
            #5

            this gives an error in this line mnuSubMenu = mnuPop->GetSubMenu(0); i tried this out: CMenu popmenu; popmenu.EnableMenuItem(ID_CONFIGURE_UPDATE,MF_GRAYED); in the on click of the submenu item. but this gives a crash for me

            H 1 Reply Last reply
            0
            • S Sunshine Always

              this gives an error in this line mnuSubMenu = mnuPop->GetSubMenu(0); i tried this out: CMenu popmenu; popmenu.EnableMenuItem(ID_CONFIGURE_UPDATE,MF_GRAYED); in the on click of the submenu item. but this gives a crash for me

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Is mnuPop valid and what return values of mnuSubMenu


              WhiteSky


              1 Reply Last reply
              0
              • S Sunshine Always

                hi how do i disable a submenu item when i select another submenu item? thanks

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                Sunshine Always wrote:

                how do i disable a submenu item when i select another submenu item?

                you cannot hide/unhide teh menu item on runtime.. except if you creating menu on runtime.. you only can disable and enable the menu item

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

                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