Solved

Open a MDIFrameWnd

Posted on 1998-09-22
2
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

631 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