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. Disable and grey out menu item

Disable and grey out menu item

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++announcement
5 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.
  • J Offline
    J Offline
    Johpoke
    wrote on last edited by
    #1

    In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!

    //Johannes

    M L M J 4 Replies Last reply
    0
    • J Johpoke

      In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!

      //Johannes

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

      1. Make the controls disabled in the dialog template 2. In OnInitDialog(), set a timer 3. In OnTimer(), enable the controls.

      --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Hungarian notation FTW

      1 Reply Last reply
      0
      • J Johpoke

        In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!

        //Johannes

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        Some of the command routing for like menus is not hooked up from CDialog. You can hook it up yourself somehow... I forget... search on MSDN (Using Google if I were you) to find some really really old articles or technical notes about this that show you how to solve the problem.

        1 Reply Last reply
        0
        • J Johpoke

          In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!

          //Johannes

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          There's also CWnd::UpdateDialogControls() which allows the use of ON_UPDATE_COMMAND_UI in dialogs. Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          • J Johpoke

            In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out? thanks!

            //Johannes

            J Offline
            J Offline
            Johpoke
            wrote on last edited by
            #5

            Ive looked at UpdateDialogControls() and it seems to be connected with UPDATE_COMMAND_UI. Ive searched around alot, on iGoogle, MSDN and codeproject yet not found something simple and working.. Another thing i dont understand is that UPDATE_COMMAND_UI seems to be executed when the menu item is clicked? but it cant really be clicked if it is disabled... Why cant it be as easy as to enable/disable the other dialog controls.... Thanks for the help :)

            //Johannes

            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