Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Open a MDIFrameWnd

Posted on 1998-09-22
2
Medium Priority
?
156 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 60 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

730 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