How to Create a Minimized/Maximized MDI Child Window

Last reviewed: October 10, 1997
Article ID: Q142317
1.00 1.50 1.51 1.52 | 1.00 2.00 2.10 2.20 4.00
WINDOWS             | WINDOWS NT
kbprg kbhowto kbcode

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 2.1,
          2.2, 4.0
        - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, 1.52
    

SUMMARY

To create an initially minimized or maximized document in an MDI application, derive a class from CMDIChildWnd and override ActivateFrame(). In the ActivateFrame() member function, call the ActivateFrame() function in the base class, and pass SW_SHOWMINIMIZED or SW_SHOWMAXIMIZED as the parameter.

MORE INFORMATION

If you're using a version of Visual C++ earlier than 4.0, it is necessary to derive a class from CMDIChildWnd and substitute the new class name in the CMultiDocTemplate used in your CWinApp-derived InitInstance() function. To do so, use ClassWizard to add a class called CChildFrame derived from CMDIChildWnd. Include the header file in your application's .cpp file. Then change the line indicated below in your InitInstance() function:

    CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(
        IDR_MDIAPPTYPE,
        RUNTIME_CLASS(CMDIAppDoc),
        RUNTIME_CLASS(CChildFrame), // change CMDIChildWnd to CChildFrame
        RUNTIME_CLASS(CMDIAppView));
    AddDocTemplate(pDocTemplate);

In Visual C++ 4.0, deriving a class from CMDIChildWnd is not required because one is already provided for you.

In the CChildFrame class, override the ActivateFrame() member function as follows:

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

    CMDIChildWnd::ActivateFrame(nCmdShow);
}


Additional reference words: kbinf 1.00 2.00 2.10 2.20 4.00 1.50
KBCategory: kbprg kbhowto kbcode
KBSubcategory: MfcDocView
Keywords : MfcDocView kbcode kbhowto kbprg
Technology : kbMfc
Version : 1.00 1.50 1.51 1.52 | 1.00 2.00
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.