Show/Hide Dialogbar, Toolbar, and Statusbar
Author |
Message |
Tony #1 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
AppWizard has created a nice SDI app framework for me, with a toolbar, status bar, and a dialog bar. The Views menu has items for showing/hiding the first two, but not the dialogbar. I can't find the handlers for hiding/showing the toolbar and status bar, so I'm not sure how to create a matching handler to show/hide the dialogbar. I do know how to add an item to the view menu, create a handler, and tie them together, and have done so successfully. I'm just surprised that there isn't any "OnViewToolbar()" handler in CMainFrame, where I would expect it to be, since the frame hosts the *bars and owns the m_wndToolbar object. Where is the show/hide toolbar handler, and how, and where, do I write the OnViewDialogbar() handler? Thanks, Tony
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
Douglas Peterso #2 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
I believe you can simply add these to your message map: ON_UPDATE_COMMAND_UI(ID_MYDIALOGBAR, OnUpdateControlBarMenu) ON_COMMAND_EX(ID_MYDIALOGBAR, OnBarCheck) and make sure that when you create your dialog bar, you use ID_MYDIALOGBAR as it's ID. Both functions are defined in CFrameWnd p.s. I figured this out by doing a search for ID_VIEW_TOOLBAR in the MFC source code which gave me the CFrameWnd message map entry. 'tis a good thing to note for future problem solving. Quote:
> AppWizard has created a nice SDI app framework for me, with a toolbar, > status bar, and a dialog bar. The Views menu has items for showing/hiding > the first two, but not the dialogbar. > I can't find the handlers for hiding/showing the toolbar and status bar, so > I'm not sure how to create a matching handler to show/hide the dialogbar. I > do know how to add an item to the view menu, create a handler, and tie them > together, and have done so successfully. I'm just surprised that there isn't > any "OnViewToolbar()" handler in CMainFrame, where I would expect it to be, > since the frame hosts the *bars and owns the m_wndToolbar object. Where is > the show/hide toolbar handler, and how, and where, do I write the > OnViewDialogbar() handler? > Thanks, > Tony
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
Douglas Peterso #3 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
... And the ID you give the menu item also has to be ID_MYDIALOGBAR, or whatever you like just as long as they are the same in all 4 places.
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
Ajay Kalr #4 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
These handlers are located in WinFrm.cpp. Search for OnUpdateControlBarMenu() in MFC source. This method hides/shows control bars: // In WINFRM.CPP void CFrameWnd::OnUpdateControlBarMenu(CCmdUI* pCmdUI) { Quote: }
-- Ajay Kalra
Quote:
>AppWizard has created a nice SDI app framework for me, with a toolbar, >status bar, and a dialog bar. The Views menu has items for showing/hiding >the first two, but not the dialogbar. >I can't find the handlers for hiding/showing the toolbar and status bar, so >I'm not sure how to create a matching handler to show/hide the dialogbar. I >do know how to add an item to the view menu, create a handler, and tie them >together, and have done so successfully. I'm just surprised that there isn't >any "OnViewToolbar()" handler in CMainFrame, where I would expect it to be, >since the frame hosts the *bars and owns the m_wndToolbar object. Where is >the show/hide toolbar handler, and how, and where, do I write the >OnViewDialogbar() handler? >Thanks, >Tony
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
Jas Trounso #5 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
Just use Class Wizard to add a message handler for a menu item and use CWnd::ShowWindow().. Quote:
>AppWizard has created a nice SDI app framework for me, with a toolbar, >status bar, and a dialog bar. The Views menu has items for showing/hiding >the first two, but not the dialogbar. >I can't find the handlers for hiding/showing the toolbar and status bar, so >I'm not sure how to create a matching handler to show/hide the dialogbar. I >do know how to add an item to the view menu, create a handler, and tie them >together, and have done so successfully. I'm just surprised that there isn't >any "OnViewToolbar()" handler in CMainFrame, where I would expect it to be, >since the frame hosts the *bars and owns the m_wndToolbar object. Where is >the show/hide toolbar handler, and how, and where, do I write the >OnViewDialogbar() handler? >Thanks, >Tony
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
Tony #6 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
I don't think that will do it. It's using the "rebar" style, and that just makes it disappear from the rebar, leaving an empty bar. Tony Quote:
>Just use Class Wizard to add a message handler for a menu item and use >CWnd::ShowWindow()..
>>AppWizard has created a nice SDI app framework for me, with a toolbar, >>status bar, and a dialog bar. The Views menu has items for showing/hiding >>the first two, but not the dialogbar. >>I can't find the handlers for hiding/showing the toolbar and status bar, so >>I'm not sure how to create a matching handler to show/hide the dialogbar. I >>do know how to add an item to the view menu, create a handler, and tie them >>together, and have done so successfully. I'm just surprised that there >isn't >>any "OnViewToolbar()" handler in CMainFrame, where I would expect it to be, >>since the frame hosts the *bars and owns the m_wndToolbar object. Where is >>the show/hide toolbar handler, and how, and where, do I write the >>OnViewDialogbar() handler? >>Thanks, >>Tony
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
Tony #7 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
I'm sorry, but I still don't get it. I'm getting closer, though. Thanks for pointing out the location of the MFC source in the CFrameWnd parent class. Maybe the problem is that this "dialogbar" is a rebar, or I guess it is included in The Rebar. I didn't ask AppWizard for a "dialogbar" when I created it, but I *did* ask for "rebar style" and maybe this is what that means. Either way, I'm glad I have this extra toolbar 'cause I need it. I took a look at the MFC source (copied below), and thought I'd try creating a menu item with the ID "ID_VIEW_REBAR", just for the heck of it. With no other modifications, this made my dialog bar show/hide just fine, but it took out the toolbar with it. It seems as though this "rebar" hosts both the toolbar and the dialog bar. Somewhere in all this framework is a piece of code that lets the toolbar disappear and reappear independent of the whole rebar, and I'd like to do the same with the dialog bar. It appears to me as though the "OnBarCheck" does the showing and hiding, but I don't see what the toolbar has that the dialogbar lacks. Here's the source from CFrameWnd. Any suggestions on how I can get this dialogbar to show and hide just like the toolbar does without showing and hiding the whole rebar? Thanks, Tony ===================== QUOTED MFC SOURCE ================= Here's the message map in CFrameWnd, including their comment line: // turning on and off standard frame gadgetry ON_UPDATE_COMMAND_UI(ID_VIEW_STATUS_BAR, OnUpdateControlBarMenu) ON_COMMAND_EX(ID_VIEW_STATUS_BAR, OnBarCheck) ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR, OnUpdateControlBarMenu) ON_COMMAND_EX(ID_VIEW_TOOLBAR, OnBarCheck) ON_UPDATE_COMMAND_UI(ID_VIEW_REBAR, OnUpdateControlBarMenu) ON_COMMAND_EX(ID_VIEW_REBAR, OnBarCheck) And here are the two functions mapped: void CFrameWnd::OnUpdateControlBarMenu(CCmdUI* pCmdUI) { ASSERT(ID_VIEW_STATUS_BAR == AFX_IDW_STATUS_BAR); ASSERT(ID_VIEW_TOOLBAR == AFX_IDW_TOOLBAR); ASSERT(ID_VIEW_REBAR == AFX_IDW_REBAR); CControlBar* pBar = GetControlBar(pCmdUI->m_nID); if (pBar != NULL) { pCmdUI->SetCheck((pBar->GetStyle() & WS_VISIBLE) != 0); return; } pCmdUI->ContinueRouting(); Quote: }
BOOL CFrameWnd::OnBarCheck(UINT nID) { ASSERT(ID_VIEW_STATUS_BAR == AFX_IDW_STATUS_BAR); ASSERT(ID_VIEW_TOOLBAR == AFX_IDW_TOOLBAR); ASSERT(ID_VIEW_REBAR == AFX_IDW_REBAR); CControlBar* pBar = GetControlBar(nID); if (pBar != NULL) { ShowControlBar(pBar, (pBar->GetStyle() & WS_VISIBLE) == 0, FALSE); return TRUE; } return FALSE; Quote: }
|
Mon, 09 Jul 2001 03:00:00 GMT |
|
 |
MCS #8 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
use CFrameWnd::ShowControlBar instead -- ---------------------------------------- Rajesh Parikh Microsoft Certified Solution Developer
---------------------------------------- Quote:
>Just use Class Wizard to add a message handler for a menu item and use >CWnd::ShowWindow()..
>>AppWizard has created a nice SDI app framework for me, with a toolbar, >>status bar, and a dialog bar. The Views menu has items for showing/hiding >>the first two, but not the dialogbar. >>I can't find the handlers for hiding/showing the toolbar and status bar, so >>I'm not sure how to create a matching handler to show/hide the dialogbar. I >>do know how to add an item to the view menu, create a handler, and tie them >>together, and have done so successfully. I'm just surprised that there >isn't >>any "OnViewToolbar()" handler in CMainFrame, where I would expect it to be, >>since the frame hosts the *bars and owns the m_wndToolbar object. Where is >>the show/hide toolbar handler, and how, and where, do I write the >>OnViewDialogbar() handler? >>Thanks, >>Tony
|
Tue, 10 Jul 2001 03:00:00 GMT |
|
 |
Anders N Weinste #9 / 9
|
 Show/Hide Dialogbar, Toolbar, and Statusbar
Quote:
>I can't find the handlers for hiding/showing the toolbar and status bar, so
One not-clearly-documented trick is that the very same numerical ID value is used for the built-in ID_VIEW_TOOLBAR command id as for the child window ID of the bar AFX_IDW_TOOLBAR. Then any of the bar commands can be mapped to the same generic handler OnBarCheck via ON_COMMAND_EX (to pass the cmd ID = bar ID).
|
Tue, 10 Jul 2001 03:00:00 GMT |
|
|
|