Solved

Open a MDIFrameWnd

Posted on 1998-09-22
2
149 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

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
ORA-01403: no data found 43 90
isEverywhere  challenge 19 72
Window placement 17 77
zeroMAx challenge 20 88
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…
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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