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. Other Discussions
  3. Article Writing
  4. ON_COMMAND_UI for Dialog Tutorial/Example

ON_COMMAND_UI for Dialog Tutorial/Example

Scheduled Pinned Locked Moved Article Writing
tutorialc++question
3 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.
  • M Offline
    M Offline
    Matt Philmon
    wrote on last edited by
    #1

    I have an MFC Dialog based application. Using other code samples I added a toolbar to my dialog and added support for the tooltips, etc. It works great. I have a couple instances where I need to disable some of the buttons on the toolbar. I figured out a way to do this with using CToolBar::GetToolBarCtrl function and using the SetState function with the indeterminate flag. However, all my reading suggests that the proper way to do this is to use ON_COMMAND_UI for the button I want to disable. Well, ON_COMMAND_UI needs a CFrame to work correctly. For a dialog, the ON_COMMAND_UI handlers you set up for each button on the toolbar is never even called so I can't call the pCmdUI->Enable(false) to disable the item. If you are writing a dialog based app (as I am) your best bet currently appears to be to use WM_KICKIDLE instead. However, that doesn't give me the ON_COMMAND_UI handler I need (the CCmdUI pointer). I could use OnKickIdle and call the OnCommandIUI handlers myself creating and passing a pointer to a CCmdUI object I populate myself but I can't seem to get this to work. Could someone tell me the proper way and demonstrate fully? I've tried so many different things without success and while my hack(?) appears to work, I'd like to do it the proper way. Thanks. Matt Philmon

    M 1 Reply Last reply
    0
    • M Matt Philmon

      I have an MFC Dialog based application. Using other code samples I added a toolbar to my dialog and added support for the tooltips, etc. It works great. I have a couple instances where I need to disable some of the buttons on the toolbar. I figured out a way to do this with using CToolBar::GetToolBarCtrl function and using the SetState function with the indeterminate flag. However, all my reading suggests that the proper way to do this is to use ON_COMMAND_UI for the button I want to disable. Well, ON_COMMAND_UI needs a CFrame to work correctly. For a dialog, the ON_COMMAND_UI handlers you set up for each button on the toolbar is never even called so I can't call the pCmdUI->Enable(false) to disable the item. If you are writing a dialog based app (as I am) your best bet currently appears to be to use WM_KICKIDLE instead. However, that doesn't give me the ON_COMMAND_UI handler I need (the CCmdUI pointer). I could use OnKickIdle and call the OnCommandIUI handlers myself creating and passing a pointer to a CCmdUI object I populate myself but I can't seem to get this to work. Could someone tell me the proper way and demonstrate fully? I've tried so many different things without success and while my hack(?) appears to work, I'd like to do it the proper way. Thanks. Matt Philmon

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

      Your OnKickIdle() handler should call UpdateDialogControls(this, FALSE); which will call the UPDATE_COMMAND_UI handlers for you. --Mike-- http://home.inreach.com/mdunn/ The preferred snack of 4 out of 5 Lounge readers.

      M 1 Reply Last reply
      0
      • M Michael Dunn

        Your OnKickIdle() handler should call UpdateDialogControls(this, FALSE); which will call the UPDATE_COMMAND_UI handlers for you. --Mike-- http://home.inreach.com/mdunn/ The preferred snack of 4 out of 5 Lounge readers.

        M Offline
        M Offline
        Matt Philmon
        wrote on last edited by
        #3

        True enough... but not for Toolbar buttons. UpdateDialogControls will get UPDATE_COMMAND_UI working for standard controls(buttons, text boxes, whatever) but not for a toolbar button. I'm not EXACTLY sure for the reason. Maybe it's because toolbars aren't exactly intended to Dialog base apps.

        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