?
Solved

Maximize MDI Child window when Main window is maximized

Posted on 2004-10-18
16
Medium Priority
?
887 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
[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
  • 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
Get MongoDB database support online, now!

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

 

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 100 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

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.

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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

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