Help on closing an MDI document window

Posted on 2003-02-25
Medium Priority
Last Modified: 2013-11-20
I’m writing an MDI-Doc/View application. I have added one option that reads a file from the disk and displays its contents in a new MDI window (Here, I'm not using the standard serialization mechanism). This works fine, the only problem I have is that if there already exists an MDI child window, I would like to automatically close it (if it’s empty, of course). What would be the best way to do that?

Thanks for your help.
Question by:elito
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
LVL 12

Accepted Solution

migel earned 400 total points
ID: 8019387
You have to use MDIDestroy method:
for example:

// CMainFrame::OnCloseWindow() is a menu command handler for
// CMainFrame class, which in turn is a CMDIFrameWnd-derived
// class. It closes and destroys the current active MDI child window.
void CMainFrame::OnCloseWindow()
   CMDIChildWnd* child = MDIGetActive();
   if (child)


Author Comment

ID: 8020793
But this will close the current active child window, I want to close an empty document window.
LVL 12

Expert Comment

ID: 8023647
Okay just found it and close :-)
To enumerate all windows for one document type you can use DocTemplate class ->from this class you can get all views associated with given document type and so on.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

770 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