CToolbar - diable item
-
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
-
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
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)
-
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
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 ofpBar->GetToolBarCtrl
wherepBar
is yourCToolBar
. Then you have access to theEnableButton()
and other functions of the same kind using theCToolBarCtrl
. Hope this helps... ~RaGE();