Closing a floated second toolbar - reflecting in menu

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a toolbar related problem. The problem is fairly minor but I’d love to get it right. I wonder if anyone could help.
I have added a toolbar to an SDI program written in VC++5. Everything works fine except that if my toolbar is floated and then closed using the X button, the View menu still shows it as checked. This doesn’t happen with the main toolbar. Presumably I need to catch my toolbar being closed and then uncheck the menu item.
Having created the toolbar I added a corresponding entry in the View menu so at program startup the View menu contains entries for Main toolbar, Second toolbar and Status bar, all checked.
Then in MainFrm.h I declared the second toolbar variable alongside the main one and added a global shown/hidden flag.
BOOL m_graphicsBarVisible;
protected:
CToolBar m_wndToolBar,m_graphicsBar;
I added event handlers in MainFrm.cpp
void CMainFrame::OnViewToolbar2()
{
m_graphicsBarVisible=(!m_graphicsBarVisible);
ShowControlBar(&m_graphicsBar,m_graphicsBarVisible,FALSE);
}
void CMainFrame::OnUpdateViewToolbar2(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_graphicsBarVisible);
}
and in OnCreate()all the standard creation statements that are done for the main toolbar m_wndToolBar, I duplicated for my toolbar m_graphicsBar.

View the full article
 
Back
Top