Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hiding a MDI child window

Posted on 1997-09-02
7
Medium Priority
?
419 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
Industry Leaders: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

610 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