Problem in Enable and disable ToolBar
-
Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....
-
Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....
mohindar_kks wrote:
m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED);
Are you sure,
GetToolBarCtrl
is returning some valid pointer. Probably, it is returingNULL
value.mohindar_kks wrote:
(abnormal termination error are occure)
This statement leads to above guess.
Prasad MS MVP - VC++
-
mohindar_kks wrote:
m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED);
Are you sure,
GetToolBarCtrl
is returning some valid pointer. Probably, it is returingNULL
value.mohindar_kks wrote:
(abnormal termination error are occure)
This statement leads to above guess.
Prasad MS MVP - VC++
Hi, Am also try to run the following code, here also abnormal termination error are occured CToolBar c_oToolBar; CToolBarCtrl & a_roCtrl = c_oToolBar.GetToolBarCtrl(); a_roCtrl.EnableButton(ID_FILE_OPEN,FALSE);
-
Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....
I am not sure about the approach that u have specified here. But the following approach will server the purpose of enabling / disabling the tool bar controls. You need to add a function in your view class. For example… Add ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) at location shown. CMyView.cpp file ======================================================= BEGIN_MESSAGE_MAP(CMyView, CScrollView) //{{AFX_MSG_MAP(CMyView) other message handler functions... ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) other message handler functions... END_MESSAGE_MAP() Void CMyView:: OnUpdateFileNew(CCmdUI* pCmdUI) { if( some_Condition) pCmdUI->Enable(true); else pCmdUI->Enable(false); } CMyView.h file Public: void OnUpdateFileNew (CCmdUI* pCmdUI); Framework will keep calling OnUpdateFileNew function frequently and will keep the tool bar option enabled or disabled in a way u want.
Sameer Thakur
-
Hi, In my poject want to disable and enable ToolBar Button(save,open,new..) at runtime using view class. I had used following code but this code not work properly(abnormal termination error are occure) CToolBar m_wndToolBar; m_wndToolBar.GetToolBarCtrl().SetState(ID_FILE_NEW,TBSTATE_ENABLED); m_wndToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW,FALSE); Please help me....
You're getting a failed assert because
m_wndToolBar
is just a C++ object, it's not a window so you can't use the methods that operate on the underlying toolbar window.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Dunder-Mifflin, this is Pam.
-
I am not sure about the approach that u have specified here. But the following approach will server the purpose of enabling / disabling the tool bar controls. You need to add a function in your view class. For example… Add ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) at location shown. CMyView.cpp file ======================================================= BEGIN_MESSAGE_MAP(CMyView, CScrollView) //{{AFX_MSG_MAP(CMyView) other message handler functions... ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew ) other message handler functions... END_MESSAGE_MAP() Void CMyView:: OnUpdateFileNew(CCmdUI* pCmdUI) { if( some_Condition) pCmdUI->Enable(true); else pCmdUI->Enable(false); } CMyView.h file Public: void OnUpdateFileNew (CCmdUI* pCmdUI); Framework will keep calling OnUpdateFileNew function frequently and will keep the tool bar option enabled or disabled in a way u want.
Sameer Thakur
I had solve the problem from your valuable reply
-
I had solve the problem from your valuable reply
Excellent. :)
Sameer Thakur