Solved

Maximize MDI Child window when Main window is maximized

Posted on 2004-10-18
16
864 Views
Last Modified: 2013-11-20
Hello,


I am working with MDI application.  When I maximize my main window, my child windows should also be maximized. Can anyone please help me to do this?

Thanks

osi-sys
0
Comment
Question by:osi-sys
  • 9
  • 7
16 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12344785
Override PreCreateWindow, ActivateFrame of CChildFrame and do the following


BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
      // TODO: Modify the Window class or styles here by modifying
      //  the CREATESTRUCT cs

      cs.style &= ~WS_SYSMENU;
      if( !CMDIChildWnd::PreCreateWindow(cs) )
            return FALSE;

      return TRUE;
}


void CChildFrame::ActivateFrame(int nCmdShow)
{
      if (nCmdShow == -1)
        nCmdShow = SW_SHOWMAXIMIZED;
            
      CMDIChildWnd::ActivateFrame(nCmdShow);
}

Good Luck
~R
0
 

Author Comment

by:osi-sys
ID: 12344864
Hi roshmon

Thanks for your help.

I did not remove the SYSMENU form CChildFrame  as user should be given the option for minimising and maximizing the child window.

Hence I wrote only this part
void CChildFrame::ActivateFrame(int nCmdShow)
{
     if (nCmdShow == -1)
        nCmdShow = SW_SHOWMAXIMIZED;
         
     CMDIChildWnd::ActivateFrame(nCmdShow);
}
This works fine when the application is started, I am showing main window in maximize mode initially. So child frame also is maximized. But when I click change the main window size and again maximize the main window, the child frame window is not getting maximized.

Can you please suggest how to proceed further?

Thanks
Madhavi



   
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12344893
Hi Madhavi,
override CMainFrame's ActivateFrame and call active child frame's SHowWindow(SW_SHOWMAXIMIZE)

~Roshan
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:osi-sys
ID: 12344988
Hi Roshan,

ActivateFrame handler of CMainFrame is not called at all. I checked using a messagebox.
ActivateFrame handler of CMDIChildWnd is called only once when new child view is craeted from File ->new .
I want my childd window to be maximized whenever Mainframe window is maximized.

Can you please suggest how to proceed further?

Thanks
Madhavi
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12345019
hi,

can u make little bit clear, itz working for me..i tried resizing of main frame and maximiz...child is also maximizing...

~Roshan
0
 

Author Comment

by:osi-sys
ID: 12345056
Hi Roshan

void CChildFrame::ActivateFrame(int nCmdShow)
{
       if (nCmdShow == -1)
        nCmdShow = SW_SHOWMAXIMIZED;
      AfxMessageBox(_TEXT("Active-------Child"));
      CMDIChildWnd::ActivateFrame(nCmdShow);
}

void CMainFrame::ActivateFrame(int nCmdShow)
{

      CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
      CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame();
      pChild->ShowWindow(SW_MAXIMIZE);
      AfxMessageBox(_TEXT("Active   --Frame"));
      CMDIFrameWnd::ActivateFrame(nCmdShow);
}

I added the above code. For me ActivateFrame of CMainFrame is not getting called.

Madhavi
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12345089
Only "void CChildFrame::ActivateFrame(int nCmdShow)" is needed, thatz working for me

~R
0
 

Author Comment

by:osi-sys
ID: 12345119
Hi

It's only working for the first time at application startup. Later when I resize the child window, and then resize the main window i.e maximize it, child window is not maximized.

Can you please post me the application to jmadhavi@yahoo.com

Thanks
Madhavi
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12345134
oh now i got... u r resizing the child window after that right?

Map CmainFrame's WM_SIZE (ie. OnSize) and try the skelton code

CView *pView = GetActiveView();
pView->GetParent()->ShowWindow(SW_SHOWMAXIMIZE);


this is just a rought code may need some modification...

btw r u from india?

~Roshan
0
 

Author Comment

by:osi-sys
ID: 12345486
Hi,

Yes  I am from India.]

yes I am resizing both the child window and parent window i.e Mainframe window after that . I am trying, but still I'm unable to do it.

Can you please let me know if you find any solution.

Thanks
Madhavi
0
 

Author Comment

by:osi-sys
ID: 12345505
Hi

I could get it.

Thanks for your help.

Madhavi
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12345532
map WM_SIZE of CMainFrame, and try following code

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
      CMDIFrameWnd::OnSize(nType, cx, cy);
      
      CFrameWnd *pFrame = GetActiveFrame();

      if ( pFrame )
            pFrame->ShowWindow(SW_MAXIMIZE);      
}

~Roshan
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 25 total points
ID: 12345540
:-(
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12345618
:-)
where in india?
~R
0
 

Author Comment

by:osi-sys
ID: 12345722
Hyderabad
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 12345759
:-)
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
abstract class with all non abstract mentods 6 76
zeroMAx challenge 20 100
JQuery serialize and unserialize 8 79
Problem to App source 6 39
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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