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. EnableMenuItem does not work

EnableMenuItem does not work

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

    I have an application with a menu that I want to disable one command in it. I write: CMenu *pmenu; pmenu=CMaimFrame::GetMenu(); pMenu->EnableMenuItem (ID_FILE_OPEN,MF_BYCOMMAND|MF_GRAYED); But the item will not go gray !!! Shay

    V M 2 Replies Last reply
    0
    • S Shay Harel

      I have an application with a menu that I want to disable one command in it. I write: CMenu *pmenu; pmenu=CMaimFrame::GetMenu(); pMenu->EnableMenuItem (ID_FILE_OPEN,MF_BYCOMMAND|MF_GRAYED); But the item will not go gray !!! Shay

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Include MF_DISABLED. See if that does it. EnableMenuItem (ID_FILE_OPEN, MF_BYPOSITION|MF_DISABLED|MF_GRAYED) Kuphryn

      S 1 Reply Last reply
      0
      • V valikac

        Include MF_DISABLED. See if that does it. EnableMenuItem (ID_FILE_OPEN, MF_BYPOSITION|MF_DISABLED|MF_GRAYED) Kuphryn

        S Offline
        S Offline
        Shay Harel
        wrote on last edited by
        #3

        Not working. I have a strange feeling that it's not pointing to my menu, If I type CMeny *pmenu=GetMenu(); pmenu->DestroyMenu(); Nothing happened .....

        1 Reply Last reply
        0
        • S Shay Harel

          I have an application with a menu that I want to disable one command in it. I write: CMenu *pmenu; pmenu=CMaimFrame::GetMenu(); pMenu->EnableMenuItem (ID_FILE_OPEN,MF_BYCOMMAND|MF_GRAYED); But the item will not go gray !!! Shay

          M Offline
          M Offline
          Mike Upton
          wrote on last edited by
          #4

          Since you're using an MFC app, you should probably be using command update handlers to deal with enabling/disabling menu items. See Mike Dunn's C++ FAQ section 7.1[^] for more information.


          "We are the knights who say Ni" (The Knights Who Say Ni)

          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