Solved

Open a MDIFrameWnd

Posted on 1998-09-22
2
148 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
Comment Utility
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
Comment Utility
Thanx :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
method notes when mouse over in eclipse 5 66
sum28 challenge 31 95
Fibonacci challenge 11 82
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

10 Experts available now in Live!

Get 1:1 Help Now