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. CToolbar - diable item

CToolbar - diable item

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 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
    jafrazee
    wrote on last edited by
    #1

    I have a toolbar that under certain conditions i may need to diable an item. how can this be done? the only set function i can find is SetButtonInfo. i tried to change the state of the toolbar button to point to an id with out a function. i noted if i do that as i am building the toolbar and did not yet attach a function to it that is shows diabled. i tried the following CToolBar* pBar = &m_wndToolBar; if (pBar != NULL) { pBar->SetButtonInfo(11,ID_NULL,TBBS_BUTTON,11); } this had no effect on the toolbar. thank you for any help

    M R 2 Replies Last reply
    0
    • J jafrazee

      I have a toolbar that under certain conditions i may need to diable an item. how can this be done? the only set function i can find is SetButtonInfo. i tried to change the state of the toolbar button to point to an id with out a function. i noted if i do that as i am building the toolbar and did not yet attach a function to it that is shows diabled. i tried the following CToolBar* pBar = &m_wndToolBar; if (pBar != NULL) { pBar->SetButtonInfo(11,ID_NULL,TBBS_BUTTON,11); } this had no effect on the toolbar. thank you for any help

      M Offline
      M Offline
      Mike Upton
      wrote on last edited by
      #2

      The easiest and cleanest way to handle enabling/disabling any UI item in an MFC app is by using update handlers, which can be added with the ClassWizard. Search in MSDN for things like the ON_UPDATE_COMMAND_UI macro and CCmdUI objects, and have a look at MFC Technical Note 021 (TN021 in the index). The automatic disabling of toolbar buttons and menu entries without command handlers is also dealt with through the same architecture, and can be disabled by setting the m_bAutoMenuEnable member of your main frame window to false. See also Mike Dunn's C++ FAQ q.7.1


      "We are the knights who say Ni" (The Knights Who Say Ni)

      1 Reply Last reply
      0
      • J jafrazee

        I have a toolbar that under certain conditions i may need to diable an item. how can this be done? the only set function i can find is SetButtonInfo. i tried to change the state of the toolbar button to point to an id with out a function. i noted if i do that as i am building the toolbar and did not yet attach a function to it that is shows diabled. i tried the following CToolBar* pBar = &m_wndToolBar; if (pBar != NULL) { pBar->SetButtonInfo(11,ID_NULL,TBBS_BUTTON,11); } this had no effect on the toolbar. thank you for any help

        R Offline
        R Offline
        Rage
        wrote on last edited by
        #3

        I don´t know myself at all with Toolbars, but after a short read of the msdn, i think you could try the following : Create a CToolBarCtrl object, assign it the return value of pBar->GetToolBarCtrl where pBar is your CToolBar. Then you have access to the EnableButton() and other functions of the same kind using the CToolBarCtrl. Hope this helps... ~RaGE();

        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