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. how do you disable menu command?

how do you disable menu command?

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

    hi everyonebody, i have a popup menu, activated by right click.. i want to disable some of the commands in the menu.. i was wondering how do i do it? i've different ways, but i can't seem to get it working.. any suggestion is welcome.. thanx in advance. i've tried this: void CMyApp::OnRMrclk(....) { CMenu menu; CPoint point = GetMessagePos(); menu.LoadMenu(IDR_MENU1); menu.EnableMenuItem(ID_MENU1_ONE, MF_GRAYED); menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd()); } i've also tried this: void CMyApp::OnUpdateMenu1One(CCmdUI *pCmdUI) { CMenu * pMenu = pCmdUI->m_pMenu; pMenu->EnableMenuItem(ID_MENU1_ONE, MF_GRAYED); }

    M 1 Reply Last reply
    0
    • T trustno1

      hi everyonebody, i have a popup menu, activated by right click.. i want to disable some of the commands in the menu.. i was wondering how do i do it? i've different ways, but i can't seem to get it working.. any suggestion is welcome.. thanx in advance. i've tried this: void CMyApp::OnRMrclk(....) { CMenu menu; CPoint point = GetMessagePos(); menu.LoadMenu(IDR_MENU1); menu.EnableMenuItem(ID_MENU1_ONE, MF_GRAYED); menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd()); } i've also tried this: void CMyApp::OnUpdateMenu1One(CCmdUI *pCmdUI) { CMenu * pMenu = pCmdUI->m_pMenu; pMenu->EnableMenuItem(ID_MENU1_ONE, MF_GRAYED); }

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

      See the VC forum FAQ, 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? The correct code for the update command UI handler is

      {
      pCmdUI->Enable(FALSE);
      }

      --Mike-- If it doesn't move and it should: WD-40. If it moves and it shouldn't: duct tape. 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm

      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