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

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

Help on closing an MDI document window

Hi!
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.
0
elito
Asked:
elito
  • 2
1 Solution
 
migelCommented:
Hi!
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)
      child->MDIDestroy();
}

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

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