CFrameWnd :: OnBarCheck
-
One of my visual c++ books tells me that in order to control the showing and hiding of toolbars, create the View menu item with the same ID as the toolbar resource, and map the ON_COMMAND_EX to OnBarCheck and the update UI to OnUpdateControlBarMenu. This compiles, but it isn't doing a damn thing - the menu items aren't checked and selecting them does nothing. Has anyone else gotten this to work? thanks, Jake
-
One of my visual c++ books tells me that in order to control the showing and hiding of toolbars, create the View menu item with the same ID as the toolbar resource, and map the ON_COMMAND_EX to OnBarCheck and the update UI to OnUpdateControlBarMenu. This compiles, but it isn't doing a damn thing - the menu items aren't checked and selecting them does nothing. Has anyone else gotten this to work? thanks, Jake
Works fine for me, maybe you could post the code in question so we can take a look at it. cheers, Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)
-
Works fine for me, maybe you could post the code in question so we can take a look at it. cheers, Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)
I'm trying to get this message map code in my CMainFrame class to control showing/hiding my toolbars. I know the menu IDs are correct, because I changed the message map as a test to map to some functions I wrote, and they worked. This, however, isn't doing anything. ON_COMMAND_EX(IDR_TOOLBAR1, OnBarCheck) ON_COMMAND_EX(IDR_TOOLBAR2, OnBarCheck) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR1, OnUpdateControlBarMenu) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR2, OnUpdateControlBarMenu) This is the only code related to this - do I need anything else? Is there a problem with the CMainFrame class handling this? Ideas? thanks, Jake
-
I'm trying to get this message map code in my CMainFrame class to control showing/hiding my toolbars. I know the menu IDs are correct, because I changed the message map as a test to map to some functions I wrote, and they worked. This, however, isn't doing anything. ON_COMMAND_EX(IDR_TOOLBAR1, OnBarCheck) ON_COMMAND_EX(IDR_TOOLBAR2, OnBarCheck) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR1, OnUpdateControlBarMenu) ON_UPDATE_COMMAND_UI(IDR_TOOLBAR2, OnUpdateControlBarMenu) This is the only code related to this - do I need anything else? Is there a problem with the CMainFrame class handling this? Ideas? thanks, Jake
These are fine
ON_COMMAND_EX ( IDR_TOOLBAR1, OnBarCheck ) ON_COMMAND_EX ( IDR_TOOLBAR2, OnBarCheck )
This wont work the way you expect it too. This is because your OnUpdateControlBarMenu() handler has no way of differentiating between the two toolbars.ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateControlBarMenu ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateControlBarMenu )
You'll need to use two functions to get the desired effect.ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateToolBar1 ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateToolBar2 )
-or- You could use theON_UPDATE_COMMAND_UI_RANGE
macro.void CMainFrame::OnBarCheck ( UINT nID ) {
switch ( nID ) { case IDR\_TOOLBAR1: ShowControlBar ( &m\_wndToolBar1, !m\_wndToolBar1.IsVisible (), FALSE ); break; case IDR\_TOOLBAR2: ShowControlBar ( &m\_wndToolBar2, !m\_wndToolBar2.IsVisible (), FALSE ); break; default: break; } RecalcLayout ();
}
// ...
void CMainFrame::OnUpdateToolBar1 ( CCmdUI * pCmdUI ) {
pCmdUI->SetCheck ( m\_wndToolBar1.IsVisible () );
}
void CMainFrame::OnUpdateToolBar2 ( CCmdUI * pCmdUI ) {
pCmdUI->SetCheck ( m\_wndToolBar2.IsVisible () );
}
That should get it working for you. Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)
-
These are fine
ON_COMMAND_EX ( IDR_TOOLBAR1, OnBarCheck ) ON_COMMAND_EX ( IDR_TOOLBAR2, OnBarCheck )
This wont work the way you expect it too. This is because your OnUpdateControlBarMenu() handler has no way of differentiating between the two toolbars.ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateControlBarMenu ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateControlBarMenu )
You'll need to use two functions to get the desired effect.ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR1, OnUpdateToolBar1 ) ON_UPDATE_COMMAND_UI ( IDR_TOOLBAR2, OnUpdateToolBar2 )
-or- You could use theON_UPDATE_COMMAND_UI_RANGE
macro.void CMainFrame::OnBarCheck ( UINT nID ) {
switch ( nID ) { case IDR\_TOOLBAR1: ShowControlBar ( &m\_wndToolBar1, !m\_wndToolBar1.IsVisible (), FALSE ); break; case IDR\_TOOLBAR2: ShowControlBar ( &m\_wndToolBar2, !m\_wndToolBar2.IsVisible (), FALSE ); break; default: break; } RecalcLayout ();
}
// ...
void CMainFrame::OnUpdateToolBar1 ( CCmdUI * pCmdUI ) {
pCmdUI->SetCheck ( m\_wndToolBar1.IsVisible () );
}
void CMainFrame::OnUpdateToolBar2 ( CCmdUI * pCmdUI ) {
pCmdUI->SetCheck ( m\_wndToolBar2.IsVisible () );
}
That should get it working for you. Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)
Thanks a lot for your help. It's finally working. Jake:-D