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 Enabling

Menu Enabling

Scheduled Pinned Locked Moved C / C++ / MFC
designquestionannouncement
6 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.
  • A Offline
    A Offline
    Anil Kumar Arvapalli
    wrote on last edited by
    #1

    I have to cal this function to enable menu.. OnUpdateFileExit(?)--- what i have to pass in place of CCmdUI argument... confused void BrowserManager::OnUpdateFileExit(CCmdUI *pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable ( TRUE ); }

    M 1 Reply Last reply
    0
    • A Anil Kumar Arvapalli

      I have to cal this function to enable menu.. OnUpdateFileExit(?)--- what i have to pass in place of CCmdUI argument... confused void BrowserManager::OnUpdateFileExit(CCmdUI *pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable ( TRUE ); }

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

      The OnUpdateXXX handlers should be called auto-magically by the framework when the message ON_UPDATE_COMMAND_UI message is sent. you need to add a message for that ... add something like in the message map area of (I don't remember which one) either the application (CWinApp derived class) or the main frame class.:

      ON_UPDATE_COMMAND_UI( ID_OF_YOUR_MENU_ITEM, OnUpdateFileExit)

      IMO, the Exit menu (quit?) should always be enable.

      Watched code never compiles.

      A 1 Reply Last reply
      0
      • M Maximilien

        The OnUpdateXXX handlers should be called auto-magically by the framework when the message ON_UPDATE_COMMAND_UI message is sent. you need to add a message for that ... add something like in the message map area of (I don't remember which one) either the application (CWinApp derived class) or the main frame class.:

        ON_UPDATE_COMMAND_UI( ID_OF_YOUR_MENU_ITEM, OnUpdateFileExit)

        IMO, the Exit menu (quit?) should always be enable.

        Watched code never compiles.

        A Offline
        A Offline
        Anil Kumar Arvapalli
        wrote on last edited by
        #3

        What i want exactly i have a menu item disabled initially.. ? I have a function which check wheteher a Sotware present in System or not and retruns true/false... If it returns true i have to enable the menu item.. If it retuns false do nothing... Can u explain me how to do this... :)

        M 1 Reply Last reply
        0
        • A Anil Kumar Arvapalli

          What i want exactly i have a menu item disabled initially.. ? I have a function which check wheteher a Sotware present in System or not and retruns true/false... If it returns true i have to enable the menu item.. If it retuns false do nothing... Can u explain me how to do this... :)

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

          The ON_UPDATE_COMMAND_UI is called for each menu item when the menu is displayed; So, when that particular menu Item is displayed, the ON_UPDATE_COMMAND_UI handler is called. In the function that you specified for the handler (usually called OnUpdateXXX where XXX is a descriptive name of the function based on the menu item) you will check to see if the software is present or not and enable disable the menu item accordingly. for example (pseudo-coded):

          ON_UPDATE_COMMAND_UI( IDM_YOUR_MENU_ITEM, OnUpdateYourMenuItem )

          void YourClass::OnUpdateYourMenuItem( CCmdUI* pCmdUI )
          {

          pCmdUI->Enable( IsSoftwarePresentOnSystem() );
          }

          If the function IsSoftwarePresentOnSystem() takes a long time, then it would be a good thing to call it somewhere else and have a state variable. Have fun. M.

          Watched code never compiles.

          A 1 Reply Last reply
          0
          • M Maximilien

            The ON_UPDATE_COMMAND_UI is called for each menu item when the menu is displayed; So, when that particular menu Item is displayed, the ON_UPDATE_COMMAND_UI handler is called. In the function that you specified for the handler (usually called OnUpdateXXX where XXX is a descriptive name of the function based on the menu item) you will check to see if the software is present or not and enable disable the menu item accordingly. for example (pseudo-coded):

            ON_UPDATE_COMMAND_UI( IDM_YOUR_MENU_ITEM, OnUpdateYourMenuItem )

            void YourClass::OnUpdateYourMenuItem( CCmdUI* pCmdUI )
            {

            pCmdUI->Enable( IsSoftwarePresentOnSystem() );
            }

            If the function IsSoftwarePresentOnSystem() takes a long time, then it would be a good thing to call it somewhere else and have a state variable. Have fun. M.

            Watched code never compiles.

            A Offline
            A Offline
            Anil Kumar Arvapalli
            wrote on last edited by
            #5

            yes dude.. I did the same way u explained... but still the menu item remains disabled.. dont know where i went wrong... :)

            M 1 Reply Last reply
            0
            • A Anil Kumar Arvapalli

              yes dude.. I did the same way u explained... but still the menu item remains disabled.. dont know where i went wrong... :)

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

              Can you debug your code ? -If you put a breakpoint in the OnUpdateXXX method, is it triggered when the menu is displayed (when you open a menu) ? -Does the function(s) that check you condition (if the software is there or not) works ? did you validate that before ? M.

              Watched code never compiles.

              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