Solved

Maximizing a MDI View

Posted on 1997-08-28
3
343 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
Comment Utility
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
Comment Utility
Sorry, that doesn't work ...
Opened 3 windows ?!?!?
And debug assertion fails !

0
 
LVL 3

Accepted Solution

by:
stefanr earned 10 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

6 Experts available now in Live!

Get 1:1 Help Now