Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

Help on closing an MDI document window

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.
  • 2
1 Solution
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)

elitoAuthor Commented:
But this will close the current active child window, I want to close an empty document window.
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now