Solved

Maximizing a MDI View

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 85
Creating Labels and Frequency list style reports in SAS code 9 92
fizzArray2 challenge 1 72
Sed question 2 68
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now