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
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.
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.
This method hides/shows control bars:
// In WINFRM.CPP
void CFrameWnd::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
{
}
--
Ajay Kalra
aka...@cse.ogi.edu
Tony wrote in message <7886ul$b2v$1...@news.ncal.verio.com>...
Tony
Jas Trounson wrote in message <36a7e...@larry.urs2.net>...
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();
}
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;
}
--
----------------------------------------
Rajesh Parikh
Microsoft Certified Solution Developer
rpa...@usa.net
----------------------------------------
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).