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. Menu items disabled but appear enabled

Menu items disabled but appear enabled

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

    I am disabling some menu items based on a condition but after some dialog launch in the application, these menu item appearance changes to those of enabled. However, when I click them their appearance changes to that of a disabled button. I can also do this by simply switching focus or simply by minimize-restore of application. Why does the menu item change appearance? How can I prevent that from happening?

    D L R 3 Replies Last reply
    0
    • C cpp_prgmer

      I am disabling some menu items based on a condition but after some dialog launch in the application, these menu item appearance changes to those of enabled. However, when I click them their appearance changes to that of a disabled button. I can also do this by simply switching focus or simply by minimize-restore of application. Why does the menu item change appearance? How can I prevent that from happening?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Is this an MFC application? How are you disabling the menu items? From where, and how, are you launching the dialog box?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

      C 1 Reply Last reply
      0
      • D David Crow

        Is this an MFC application? How are you disabling the menu items? From where, and how, are you launching the dialog box?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        C Offline
        C Offline
        cpp_prgmer
        wrote on last edited by
        #3

        Yes this is a MFC application which works similar to the CProperty sheet wizard style but with CDialogs. I am disabling the menu items in the frame class when the first dialog appears at start of the application but somewhere in between when other dialogs come up the appearance of the disabled menu items is changing from disabled to enabled.

        M 1 Reply Last reply
        0
        • C cpp_prgmer

          Yes this is a MFC application which works similar to the CProperty sheet wizard style but with CDialogs. I am disabling the menu items in the frame class when the first dialog appears at start of the application but somewhere in between when other dialogs come up the appearance of the disabled menu items is changing from disabled to enabled.

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          To enable/disable menu items it is best practice to use the ON_UPDATE_COMMAND_UI message. It also best practice to use a SDI (with a CFormView) application if menus are needed.

          Watched code never compiles.

          C 1 Reply Last reply
          0
          • C cpp_prgmer

            I am disabling some menu items based on a condition but after some dialog launch in the application, these menu item appearance changes to those of enabled. However, when I click them their appearance changes to that of a disabled button. I can also do this by simply switching focus or simply by minimize-restore of application. Why does the menu item change appearance? How can I prevent that from happening?

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

            Hi, It sounds to me as if your doing something that is screwing up the MFC command routing. However based on your brief description I have no ideas as to what it could be. Did you check to see if the menu items have a unique resource ID? Best Wishes, -David Delaune

            1 Reply Last reply
            0
            • M Maximilien

              To enable/disable menu items it is best practice to use the ON_UPDATE_COMMAND_UI message. It also best practice to use a SDI (with a CFormView) application if menus are needed.

              Watched code never compiles.

              C Offline
              C Offline
              cpp_prgmer
              wrote on last edited by
              #6

              Thanks for your advice. But turns out if you try to disable the menubar items after system creates window, you need to call DrawMenuBar(). Source of explanation: http://stackoverflow.com/questions/1835209/how-can-i-disable-and-gray-the-top-level-menu-item-using-mfc?answertab=oldest#tab-top[^] This solves my problem... Hope this helps anyone else having similar issues.

              1 Reply Last reply
              0
              • C cpp_prgmer

                I am disabling some menu items based on a condition but after some dialog launch in the application, these menu item appearance changes to those of enabled. However, when I click them their appearance changes to that of a disabled button. I can also do this by simply switching focus or simply by minimize-restore of application. Why does the menu item change appearance? How can I prevent that from happening?

                R Offline
                R Offline
                rana ray
                wrote on last edited by
                #7

                Is it solved now? regards Vatsa www.objectiveprogramming.com[^]

                C 1 Reply Last reply
                0
                • R rana ray

                  Is it solved now? regards Vatsa www.objectiveprogramming.com[^]

                  C Offline
                  C Offline
                  cpp_prgmer
                  wrote on last edited by
                  #8

                  Yes my problem is solved. As replied earlier calling DrawMenuBar()solved my issue. Please refer to: http://stackoverflow.com/questions/1835209/how-can-i-disable-and-gray-the-top-level-menu-item-using-mfc[^] for more details.

                  L 1 Reply Last reply
                  0
                  • C cpp_prgmer

                    Yes my problem is solved. As replied earlier calling DrawMenuBar()solved my issue. Please refer to: http://stackoverflow.com/questions/1835209/how-can-i-disable-and-gray-the-top-level-menu-item-using-mfc[^] for more details.

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

                    Hi, I see that you showed your EnableMenuItem() function on stackoverflow. If you would have gave us a better description and shown that function here on codeproject you would have recieved a much better response. Best Wishes, -David Delaune

                    C 1 Reply Last reply
                    0
                    • L Lost User

                      Hi, I see that you showed your EnableMenuItem() function on stackoverflow. If you would have gave us a better description and shown that function here on codeproject you would have recieved a much better response. Best Wishes, -David Delaune

                      C Offline
                      C Offline
                      cpp_prgmer
                      wrote on last edited by
                      #10

                      Sorry for the confusion, let me explain. The StackOverflow post was not me, it was a reference. I could not post my code online... Company policy. However, thanks for your concern in trying to help me solve my problem. I shall continue to approach you guys in future.

                      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