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 submenu in Win32

Disabling submenu in Win32

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.
  • L Offline
    L Offline
    lclarsen
    wrote on last edited by
    #1

    Hi, I'm trying to disable a submenu in win32. It's working ok, but is there an alternative to this:

    HMENU showMenu = GetSubMenu(currentMenu,2);
    EnableMenuItem(showMenu,4,MF_BYPOSITION | MF_GRAYED);

    I don't like MF_BYPOSITION, because the code will break if we add new menu items to 'showMenu' later on. Why do sub-menus not have ID's, so that I could just call EnableMenuItem() directly...? Thanks! /lacla

    L S F 3 Replies Last reply
    0
    • L lclarsen

      Hi, I'm trying to disable a submenu in win32. It's working ok, but is there an alternative to this:

      HMENU showMenu = GetSubMenu(currentMenu,2);
      EnableMenuItem(showMenu,4,MF_BYPOSITION | MF_GRAYED);

      I don't like MF_BYPOSITION, because the code will break if we add new menu items to 'showMenu' later on. Why do sub-menus not have ID's, so that I could just call EnableMenuItem() directly...? Thanks! /lacla

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Why not use MF_BYCOMMAND against the id of the menuitem you want disabled?

      L 1 Reply Last reply
      0
      • L Lost User

        Why not use MF_BYCOMMAND against the id of the menuitem you want disabled?

        L Offline
        L Offline
        lclarsen
        wrote on last edited by
        #3

        As I indicated, submenus don't have id's as far as I can see. Otherwise I would have used the ID... It is a submenu (flyout) in the menu bar that I want to disable. /lacla

        1 Reply Last reply
        0
        • L lclarsen

          Hi, I'm trying to disable a submenu in win32. It's working ok, but is there an alternative to this:

          HMENU showMenu = GetSubMenu(currentMenu,2);
          EnableMenuItem(showMenu,4,MF_BYPOSITION | MF_GRAYED);

          I don't like MF_BYPOSITION, because the code will break if we add new menu items to 'showMenu' later on. Why do sub-menus not have ID's, so that I could just call EnableMenuItem() directly...? Thanks! /lacla

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          I think the idiomatic way to do what you want is to grey out all the items on the sub-menu rather than to disable the sub-menu itself, basically because there's less cognitive dissonance for the user.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p MVP for 2010 - who'd'a thunk it!

          L 1 Reply Last reply
          0
          • S Stuart Dootson

            I think the idiomatic way to do what you want is to grey out all the items on the sub-menu rather than to disable the sub-menu itself, basically because there's less cognitive dissonance for the user.

            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p MVP for 2010 - who'd'a thunk it!

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Stuart Dootson wrote:

            less cognitive dissonance for the user.

            That sounds like something a real MVP would say ;)

            1 Reply Last reply
            0
            • L lclarsen

              Hi, I'm trying to disable a submenu in win32. It's working ok, but is there an alternative to this:

              HMENU showMenu = GetSubMenu(currentMenu,2);
              EnableMenuItem(showMenu,4,MF_BYPOSITION | MF_GRAYED);

              I don't like MF_BYPOSITION, because the code will break if we add new menu items to 'showMenu' later on. Why do sub-menus not have ID's, so that I could just call EnableMenuItem() directly...? Thanks! /lacla

              F Offline
              F Offline
              fkeujjpdc
              wrote on last edited by
              #6

              you can set the submenu normal then add showmenu ,at last you set the showmenu MF_GRAYED,do this the code should not break

              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