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. ON_UPDATE_COMMAND_UI problem...

ON_UPDATE_COMMAND_UI problem...

Scheduled Pinned Locked Moved C / C++ / MFC
comhelpquestion
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.
  • R Offline
    R Offline
    Remi Morin
    wrote on last edited by
    #1

    I used the ON_UPDATE_COMMAND_UI message in a DialogBar to display button, this fonction do nothing. It is only usefull to avoid my DialogBar to grayed my button so the message map look like this

    BEGIN_MESSAGE_MAP(CVBurnBar, CDialogBar)
    //{{AFX_MSG_MAP(CVBurnBar)
    //...other message handler
    ON_UPDATE_COMMAND_UI(IDC_Up_Normalize_AxisY, OnUpdateButton)
    ON_UPDATE_COMMAND_UI(IDC_Bottom_Normalize_AxisY, OnUpdateButton)
    ON_UPDATE_COMMAND_UI(IDC_Bottom_Adjust_Y, OnUpdateButton)
    ON_UPDATE_COMMAND_UI(IDC_Up_Adjust_Y, OnUpdateButton)
    //}}AFX_MSG_MAP
    ON_MESSAGE(WM_INITDIALOG,OnInitDialog)
    END_MESSAGE_MAP()

    and the function

    void CVBurnBar::OnUpdateButton(CCmdUI* /* pCmdUI*/)
    {}

    but theses message handler are called very often... what can I do to avoid this function to be call so often? Is there an other way to display button NOT GRAYED in a dialog bar whitout using the ON_UPDATE_COMMAND_UI. when I do MyButton.EnableWindow(true) if the ON_UPDATE_COMMAND_UI is not define for this button it is automatically grayed after 1/10 of a second... What I wan't is to display and grayed my button when I want... any idea? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

    T C C 4 Replies Last reply
    0
    • R Remi Morin

      I used the ON_UPDATE_COMMAND_UI message in a DialogBar to display button, this fonction do nothing. It is only usefull to avoid my DialogBar to grayed my button so the message map look like this

      BEGIN_MESSAGE_MAP(CVBurnBar, CDialogBar)
      //{{AFX_MSG_MAP(CVBurnBar)
      //...other message handler
      ON_UPDATE_COMMAND_UI(IDC_Up_Normalize_AxisY, OnUpdateButton)
      ON_UPDATE_COMMAND_UI(IDC_Bottom_Normalize_AxisY, OnUpdateButton)
      ON_UPDATE_COMMAND_UI(IDC_Bottom_Adjust_Y, OnUpdateButton)
      ON_UPDATE_COMMAND_UI(IDC_Up_Adjust_Y, OnUpdateButton)
      //}}AFX_MSG_MAP
      ON_MESSAGE(WM_INITDIALOG,OnInitDialog)
      END_MESSAGE_MAP()

      and the function

      void CVBurnBar::OnUpdateButton(CCmdUI* /* pCmdUI*/)
      {}

      but theses message handler are called very often... what can I do to avoid this function to be call so often? Is there an other way to display button NOT GRAYED in a dialog bar whitout using the ON_UPDATE_COMMAND_UI. when I do MyButton.EnableWindow(true) if the ON_UPDATE_COMMAND_UI is not define for this button it is automatically grayed after 1/10 of a second... What I wan't is to display and grayed my button when I want... any idea? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      If you want your button to stay active all the time, do not create ON_UPDATE_COMMAND_UI - just ON_COMMAND handler. MFC scans through message maps during each idle cycle, which happens very often indeed. However, you shouldn't be worried much about that - it works the same way for toolbars, for example. Tomasz Sowinski -- http://www.shooltz.com

      1 Reply Last reply
      0
      • R Remi Morin

        I used the ON_UPDATE_COMMAND_UI message in a DialogBar to display button, this fonction do nothing. It is only usefull to avoid my DialogBar to grayed my button so the message map look like this

        BEGIN_MESSAGE_MAP(CVBurnBar, CDialogBar)
        //{{AFX_MSG_MAP(CVBurnBar)
        //...other message handler
        ON_UPDATE_COMMAND_UI(IDC_Up_Normalize_AxisY, OnUpdateButton)
        ON_UPDATE_COMMAND_UI(IDC_Bottom_Normalize_AxisY, OnUpdateButton)
        ON_UPDATE_COMMAND_UI(IDC_Bottom_Adjust_Y, OnUpdateButton)
        ON_UPDATE_COMMAND_UI(IDC_Up_Adjust_Y, OnUpdateButton)
        //}}AFX_MSG_MAP
        ON_MESSAGE(WM_INITDIALOG,OnInitDialog)
        END_MESSAGE_MAP()

        and the function

        void CVBurnBar::OnUpdateButton(CCmdUI* /* pCmdUI*/)
        {}

        but theses message handler are called very often... what can I do to avoid this function to be call so often? Is there an other way to display button NOT GRAYED in a dialog bar whitout using the ON_UPDATE_COMMAND_UI. when I do MyButton.EnableWindow(true) if the ON_UPDATE_COMMAND_UI is not define for this button it is automatically grayed after 1/10 of a second... What I wan't is to display and grayed my button when I want... any idea? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

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

        You should be using ON_UPDATE_COMMAND_UI_RANGE(IDC_Up_Normalise_AxisY, IDC_Up_Adjust_Y, OnUpdateButton) provided the command IDs use that range. This maps the button handlers to the same function(OnUpdateButton), something it looks like your trying to do. The function does nothing because you haven`t said for it to do anything! I think that in the CVBurnBar function, if you change the parameter to (CCmdUI* pCmdUI) i.e no comments, then you should have control to change the button i.e gray it out etc (using pCmdUI->thefunctionyouwant). Also make sure the afx_msg void OnUpdateButton in the header file is changed to reflect this. To stop the button being grayed out at the start all you need to do is add a message map for ON_COMMAND_RANGE(IDC_Up_Normalise_AxisY, IDC_Up_Adjust_Y, TheFunctionYouWantToCallWhenButtonIsClicked). hope this helped slightly.:-D AEGC

        1 Reply Last reply
        0
        • R Remi Morin

          I used the ON_UPDATE_COMMAND_UI message in a DialogBar to display button, this fonction do nothing. It is only usefull to avoid my DialogBar to grayed my button so the message map look like this

          BEGIN_MESSAGE_MAP(CVBurnBar, CDialogBar)
          //{{AFX_MSG_MAP(CVBurnBar)
          //...other message handler
          ON_UPDATE_COMMAND_UI(IDC_Up_Normalize_AxisY, OnUpdateButton)
          ON_UPDATE_COMMAND_UI(IDC_Bottom_Normalize_AxisY, OnUpdateButton)
          ON_UPDATE_COMMAND_UI(IDC_Bottom_Adjust_Y, OnUpdateButton)
          ON_UPDATE_COMMAND_UI(IDC_Up_Adjust_Y, OnUpdateButton)
          //}}AFX_MSG_MAP
          ON_MESSAGE(WM_INITDIALOG,OnInitDialog)
          END_MESSAGE_MAP()

          and the function

          void CVBurnBar::OnUpdateButton(CCmdUI* /* pCmdUI*/)
          {}

          but theses message handler are called very often... what can I do to avoid this function to be call so often? Is there an other way to display button NOT GRAYED in a dialog bar whitout using the ON_UPDATE_COMMAND_UI. when I do MyButton.EnableWindow(true) if the ON_UPDATE_COMMAND_UI is not define for this button it is automatically grayed after 1/10 of a second... What I wan't is to display and grayed my button when I want... any idea? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

          C Offline
          C Offline
          Carlos Antollini
          wrote on last edited by
          #4

          From MSDN: (TN031: Control Bars) CCmdUI Support for CDialogBar Dialog bar buttons should be updated through the ON_UPDATE_COMMAND_UI handler mechanism. At idle time, the dialog bar will call the ON_UPDATE_COMMAND_UI handler with the command ID of all the buttons that have a ID >= 0x8000 (that is, in the range of command IDs). The ON_UPDATE_COMMAND_UI handler can call: Enable: to enable or disable the button. SetText: to change the text of the button. Customization can be done through standard window manager APIs. Best Regards... Carlos Antollini. :bob: Today Is Friday!!! :beer: for All!!!

          1 Reply Last reply
          0
          • R Remi Morin

            I used the ON_UPDATE_COMMAND_UI message in a DialogBar to display button, this fonction do nothing. It is only usefull to avoid my DialogBar to grayed my button so the message map look like this

            BEGIN_MESSAGE_MAP(CVBurnBar, CDialogBar)
            //{{AFX_MSG_MAP(CVBurnBar)
            //...other message handler
            ON_UPDATE_COMMAND_UI(IDC_Up_Normalize_AxisY, OnUpdateButton)
            ON_UPDATE_COMMAND_UI(IDC_Bottom_Normalize_AxisY, OnUpdateButton)
            ON_UPDATE_COMMAND_UI(IDC_Bottom_Adjust_Y, OnUpdateButton)
            ON_UPDATE_COMMAND_UI(IDC_Up_Adjust_Y, OnUpdateButton)
            //}}AFX_MSG_MAP
            ON_MESSAGE(WM_INITDIALOG,OnInitDialog)
            END_MESSAGE_MAP()

            and the function

            void CVBurnBar::OnUpdateButton(CCmdUI* /* pCmdUI*/)
            {}

            but theses message handler are called very often... what can I do to avoid this function to be call so often? Is there an other way to display button NOT GRAYED in a dialog bar whitout using the ON_UPDATE_COMMAND_UI. when I do MyButton.EnableWindow(true) if the ON_UPDATE_COMMAND_UI is not define for this button it is automatically grayed after 1/10 of a second... What I wan't is to display and grayed my button when I want... any idea? Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

            C Offline
            C Offline
            Carlos Antollini
            wrote on last edited by
            #5

            You tried with

            void CVBurnBar::OnUpdateButton(CCmdUI* /* pCmdUI*/)
            {
            CCmdUI->Enable();
            }

            Carlos Antollini.

            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