Solved

Open a MDIFrameWnd

Posted on 1998-09-22
2
153 Views
Last Modified: 2013-11-19
How do i open a new MDIFrame window from anywhere
in my code? (if theres no MDI windows open.)
0
Comment
Question by:DanielC
2 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 20 total points
ID: 1322434
To do it the MFC way you need to open it via the doctemplate.

You will find the right doctemplate (if you have more than one), using CWinApp::GetFirstDocTemplatePosition().

Then use OpenDocumentFile() on that doctemplate, a new document, mdi child frame, etc will be created just like you would have clicked on the file new menu item.

This can be done from almost anywhere since AfxGetApp() will return the pointer to your CWinApp derived class, on which you can call a function that will open the child frame.

Example:

    CDocTemplate    *pTemplate;
    CDocBase        *pDoc;
    POSITION        posTemplate;
    POSITION        posDoc;

    posTemplate = GetFirstDocTemplatePosition();
    while(posTemplate != NULL) {
        pTemplate = GetNextDocTemplate(posTemplate);
        if( pTemplate->IsKindOf(RUNTIME_CLASS(CMyTemplated))) {
           pTemplate->OpenDocumentFile(NULL);
           break;
        }
    }

0
 

Author Comment

by:DanielC
ID: 1322435
Thanx :)
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

713 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