Solved

Maximizing a MDI View

Posted on 1997-08-28
3
350 Views
Last Modified: 2013-11-20
How can I maximize a document view in a MDI app when I create a new doc, or when I open a doc
0
Comment
Question by:onyxmedia
[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
  • 2
3 Comments
 
LVL 3

Expert Comment

by:stefanr
ID: 1305061
You could use something like this, which I have taken from a test app I made to create the initial empty document with a maximized child frame in InitInstance():

...
      CMultiDocTemplate* pDocTemplate;
      pDocTemplate = new CMultiDocTemplate(
            IDR_MDITYPE,
            RUNTIME_CLASS(CMDIDoc),
            RUNTIME_CLASS(CChildFrame), // custom MDI child frame
            RUNTIME_CLASS(CMDIView));
      AddDocTemplate(pDocTemplate);

      // create main MDI Frame window
      CMainFrame* pMainFrame = new CMainFrame;
      if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
            return FALSE;
      m_pMainWnd = pMainFrame;

      // Parse command line for standard shell commands, DDE, file open
      CCommandLineInfo cmdInfo;
      ParseCommandLine(cmdInfo);

      // Dispatch commands specified on the command line
   if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew)
   {
         if (!ProcessShellCommand(cmdInfo))
               return FALSE;
   }
   else
   {
      CDocument* pDoc = pDocTemplate->CreateNewDocument();
      CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDoc, NULL);
      pMainFrame->MDIMaximize(pFrame);
      pFrame->InitialUpdateFrame(pDoc, TRUE);
   }

      // The main window has been initialized, so show and update it.
      pMainFrame->ShowWindow(m_nCmdShow);
      pMainFrame->UpdateWindow();

      return TRUE;
}

0
 

Author Comment

by:onyxmedia
ID: 1305062
Sorry, that doesn't work ...
Opened 3 windows ?!?!?
And debug assertion fails !

0
 
LVL 3

Accepted Solution

by:
stefanr earned 10 total points
ID: 1305063
Here's another alternative:

Override the virtual function ActivateFrame in your derived CMDIChildWnd as this:

void CChildFrame::ActivateFrame(int nCmdShow)
{
   CMDIFrameWnd* pMainFrame = (CMDIFrameWnd*) ::AfxGetMainWnd();
   pMainFrame->MDIMaximize(this);
      
   CMDIChildWnd::ActivateFrame(nCmdShow);
}

Less flexible, but it should work for you.

/Stefan
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
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. …
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 Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

728 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