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. Can someone (briefly) explain ON_UPDATE_COMMAND_UI?

Can someone (briefly) explain ON_UPDATE_COMMAND_UI?

Scheduled Pinned Locked Moved C / C++ / MFC
designquestion
6 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.
  • S Offline
    S Offline
    Simon Langdon
    wrote on last edited by
    #1

    My legacy app. uses this message handler to do button enabling / disabling. However it gets called very frequently (eg on mouse move). is there any way of filtering / controlling the messages that cause this function to get called? I can't see why I'd want to do anything with my toolbars & icons in response to UI messages anyway. Thanks

    D C I 3 Replies Last reply
    0
    • S Simon Langdon

      My legacy app. uses this message handler to do button enabling / disabling. However it gets called very frequently (eg on mouse move). is there any way of filtering / controlling the messages that cause this function to get called? I can't see why I'd want to do anything with my toolbars & icons in response to UI messages anyway. Thanks

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

      Simon Langdon wrote:

      I can't see why I'd want to do anything with my toolbars & icons in response to UI messages anyway.

      You may need to disable a menu item based on some condition. You may have a counter in one of the status bar panes that needs updating. There are multiple uses for this macro.

      "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

      S 1 Reply Last reply
      0
      • D David Crow

        Simon Langdon wrote:

        I can't see why I'd want to do anything with my toolbars & icons in response to UI messages anyway.

        You may need to disable a menu item based on some condition. You may have a counter in one of the status bar panes that needs updating. There are multiple uses for this macro.

        "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

        S Offline
        S Offline
        Simon Langdon
        wrote on last edited by
        #3

        Yes, to be clear I can't see why _I_ would want to handle this message. But does MFC manage this message handler for every window in my app with a Message Map? I'm trying to decide if there's anything in my code base responsible for calling this unnecessarily.

        CPalliniC 1 Reply Last reply
        0
        • S Simon Langdon

          Yes, to be clear I can't see why _I_ would want to handle this message. But does MFC manage this message handler for every window in my app with a Message Map? I'm trying to decide if there's anything in my code base responsible for calling this unnecessarily.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Some insight here: "When Update Handlers Are Called"[^].

          Veni, vidi, vici.

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • S Simon Langdon

            My legacy app. uses this message handler to do button enabling / disabling. However it gets called very frequently (eg on mouse move). is there any way of filtering / controlling the messages that cause this function to get called? I can't see why I'd want to do anything with my toolbars & icons in response to UI messages anyway. Thanks

            C Offline
            C Offline
            chaau
            wrote on last edited by
            #5

            If the logic that decides if the buttons should be enabled or disabled is too complicated it is advised (do not ask me to find who advised it, I just remember it somehow) that you do not use this method. You could always use CToolBarCtrl::EnableButton() for this and control it from within other parts of the program

            1 Reply Last reply
            0
            • S Simon Langdon

              My legacy app. uses this message handler to do button enabling / disabling. However it gets called very frequently (eg on mouse move). is there any way of filtering / controlling the messages that cause this function to get called? I can't see why I'd want to do anything with my toolbars & icons in response to UI messages anyway. Thanks

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #6

              One place that can fire off updating is the internal OnIdle. This is a fake message handler, called from the MFC message loop. So, you'll get updates a lot, but only when the message queue has "calmed down". So, if you get it a lot, it's because you don't have a lot else going on. Iain.

              I am one of "those foreigners coming over here and stealing our jobs". Yay me!

              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