Solved

Maximizing a MDI View

Posted on 1997-08-28
3
348 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
  • 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
Perl Awk Need Help 3 129
ffmpeg - "rtsp://...... Operation not permitted" 4 86
firstChar challenge 13 121
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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