Solved

Hiding a MDI child window

Posted on 1997-09-02
7
402 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
  • 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video discusses moving either the default database or any database to a new volume.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now