Solved

Hiding a MDI child window

Posted on 1997-09-02
7
416 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 100 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
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!

 

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

Technology Partners: 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!

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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 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