Solved

Maximize MDI Child window when Main window is maximized

Posted on 2004-10-18
16
873 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 131
wait notify demo infinite loop 3 122
building a service to accessed via telnet client, want colors ? 4 92
moto 4g phone enable finger print 4 26
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. …
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

839 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