Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Show/Hide Dialogbar, Toolbar, and Statusbar

492 views
Skip to first unread message

Tony

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
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

Douglas Peterson

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
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.

Douglas Peterson

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
...

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.

Ajay Kalra

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
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)
{
}

--
Ajay Kalra
aka...@cse.ogi.edu

Tony wrote in message <7886ul$b2v$1...@news.ncal.verio.com>...

Jas Trounson

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
Just use Class Wizard to add a message handler for a menu item and use
CWnd::ShowWindow()..

Tony

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
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


Jas Trounson wrote in message <36a7e...@larry.urs2.net>...

Tony

unread,
Jan 21, 1999, 3:00:00 AM1/21/99
to
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();
}

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 (MCSD)

unread,
Jan 22, 1999, 3:00:00 AM1/22/99
to
use CFrameWnd::ShowControlBar instead

--
----------------------------------------
Rajesh Parikh
Microsoft Certified Solution Developer
rpa...@usa.net
----------------------------------------

Anders N Weinstein

unread,
Jan 22, 1999, 3:00:00 AM1/22/99
to
In article <7886ul$b2v$1...@news.ncal.verio.com>,

Tony <Tony...@memwizard.com> wrote:
>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).


0 new messages