Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Showing/Hiding toolbar

Posted on 1999-07-07
6
Medium Priority
?
350 Views
Last Modified: 2013-11-20
I have a MDI application which uses two toolbars based on the document type. Say I have MDIChild1,MDIChild2 two frame classes with toolbar1, toolbar2 associated to them.

In CMainFrame's oncreate function I create both the toolbars and show toolbar1 and hide toolbar2. Now when I open MDIChild2 frame and associted doc/view I want toolbar2 to be
visible and toolbar1 to be hidden.
So I have written following code in Overridden OnMDIActivate (WM_MDIACTIVATE)function of MDIChild2.
Everything is working as expected but when I call print preview fron MDIChild2 the print preview dilaog is shown and
when I close this Toolbar1 is also shown along with Toolbar2. Can anybody say why is this happening.
0
Comment
Question by:sangamesh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:MichaelS
ID: 1309119
I think you have to create at least three toolbars, one is default. On WM_MDIACTIVARE you have to chek and if your window is diactivates you have to set default toolbar. When one of your child is about to activate you just set the corespondent toolbar.
0
 

Expert Comment

by:sankar012898
ID: 1309120
Have U written code in WM_MDIACTIVATE  of  MDIChild1  
to show toolbar1  and hide toolbar2 ?

I think when U close the print preview dialog  , the
WM_MDIACTIVATE is getting called for  both MDIChild2
and  MDIChild1  .


Another possibility is  , when U  close the print preview dialog  , OnDraw function is getting called  for the
MDIFrameWnd  . U can   write code inside this  function
to  get the  active  MDiChildWnd  and  send a
WM_MDIACTIVATE message to it , thereby activating the appropriate  tool bar .









0
 

Author Comment

by:sangamesh
ID: 1309121
I had already tried placing showcontrolbar(.......) in OnDraw of MainFrame and it works but I am wondering why the other toolbar is being shown without that code.
Actually I want to know why it happens like that. I am listing the code I have wrriten for MDIChildWnd2's OnMDIActivate

if(bActivate)
{
showcontolbar(Toolbar1, false,false);
showcontolbar(Toolbar2, true,false);
}
else
{
showcontolbar(Toolbar1, true,false);
showcontolbar(Toolbar2, false,false);
}
CMDIChildWnd::OnMDIActivate;


else block is executed when the MDIChildWnd2 is being deactivaed
and other block is executed when the MDIChildWnd2 is being activated


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:sankar012898
ID: 1309122
check when U are setting the value of bActivate .
when are U setting the values of bActivate  to TRUE
and FALSE ?

Where are U creating the toolbars ? Is it OnCreateClient ?

Does  the ELSE block ever get executed ? because
when MDIChildWnd2  is  being  deactivated the  control
won't  come  to  MDIChildWnd2::OnMDIActivate  because
it is not getting Activated .

Also , are U showing the toolbars i.e. calling ShowControl
Bar anywhere else in the program ? whereby  Toolbar
of  MDIChild1 is being displayed











0
 

Author Comment

by:sangamesh
ID: 1309123
I have tried all but it doesn't work
0
 
LVL 1

Accepted Solution

by:
anoops earned 200 total points
ID: 1309124
Sangamesh, There are two ways to solve this problem.
1) The way in which you are trying to show/hide toolbars, where the Toolbars are members of MainFrame( Am I right there? ). BUT you have to make the Show/Hide on corresponding view's OnActivateView() override. This would work even with the printpreview case.
2) Or make each of these toolbars are members of the Child frames and create them in the OnCreate() of these Child frames( Instead of the create of the Main Frame)

0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question