?
Solved

Hiding a MDI child window

Posted on 1997-09-02
7
Medium Priority
?
418 Views
Last Modified: 2013-11-20
I'm trying to hide a MDI child window, showing it when necessary. I've attempted ShowWindow(SW_HIDE) with no success yet. I'd greatly appreciate effective suggestions of a solution.
RJV
0
Comment
Question by:RJV
[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
  • 3
  • 3
7 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 200 total points
ID: 1305577
Try ModifyStyle( WS_VISIBLE, 0, SWP_HIDEWINDOW ). This has to help you.
Good luck.
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1305578
I think the following should get the frame. Please correct me if I'm wrong (I've removed the assertions):

CMDIFrameWnd *pFrame = (CMDIFrameWnd *)pApp->m_pMainWnd;

CMDIChildWnd* pChild = pFrame->MDIGetActive();

pChild->ShowWindow(SW_HIDE);

I've tried other variations, such as calling ::ShowWindow() with the same result. It returns but the window or frame is still visible.

I'll try the ModifyWindow suggestion to see it that will do the trick. Any further suggestions and examples you might have would be a super help.

RJV

0
 

Author Comment

by:RJV
ID: 1305579
Hi AVaulin,

I tried your suggestion. Unfortunately it doesn't work, at least not yet. The child frame is still visible yet, curiously, apparently innacitve. Even a cursor bar in the text stays frozen there. Any ideas of what might be happening?

RJV

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:RJV
ID: 1305580
Add pFrame->MDINext(); between MDIGetActive and ShowWindow methods calls.
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1305581
Hi AVaulin,

I lost you there. If I add pFrame->MDINext() I should get the child window behind the one I got with  MDIGetActive(), or not? For test purposes there is only one maximized child window. Later there be either one or more child windows, all of which to be hidden.

Meanwhile I just discovered by chance that your first suggestion seems to be working. At least it works as long as one steps through the ModifyStyle( WS_VISIBLE, 0, SWP_HIDEWINDOW) call. Tell the debugger to continue at full speed after that and the child window is gone. Do it outside the debugger (i.e. Ctrl-F5 in VC++ 5.0) and you get the result described above. Thus this seems to be associated to the lack of refreshing the screen, though UpdateWindow() and Invalidate() haven't done the trick yet.

Hope this info helps.
RJV
0
 

Author Comment

by:RJV
ID: 1305582
OK! I created new MDI project and added say ID_EDIT_UNDO command handler to CMainFrame class. There are two variants of this command handler below. Each of two variants does what you want (one of them uses my first suggestion, other - second).

/*
---- first variant
*/
void CMainFrame::OnEditUndo()
{
      CMDIChildWnd* wnd = MDIGetActive();
      wnd->ModifyStyle( WS_VISIBLE, 0, SWP_HIDEWINDOW );
      wnd->RedrawWindow();
      RedrawWindow();
}

/*
---- second variant
*/
void CMainFrame::OnEditUndo()
{
      CMDIChildWnd* wnd = MDIGetActive();
      MDINext();
      wnd->ShowWindow(SW_HIDE);
}

Choose variant you like and good luck.
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1305583
Hi AVaulin,

Your second option (or variant) worked, but not the first. The only difference is that I used the original pFrame method as I couldn't get MDINext() to be recognized as a legitimate function without it. I'm still curious why getting the next child frame works while getting the first does not.

Now I just have to figure out how to keep track of the right view to bring back when necessary. Any suggestions are greatly appreciated.

RJV

PS
I'd also like to commend you on your help as some of the help in the past was quite often off target.

0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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