Write code for ‘Close All Documents’ menu command?


The ‘Close All Documents’ is a menu command that closes all the open documents and their views. This feature can be implemented by using two functions CWinApp::CloseAllDocuments( ) and SaveAllModified( ). The CloseAllDocuments( ) function destroys the currently active document objects without saving them. So we must first call SaveAllModified( ) function to save the documents. Following code shows how to implement this feature.

if ( AfxGetApp( ) -> SaveAllModified( ) )

AfxGetApp( ) -> CloseAllDocuments ( FALSEĀ  ) ;

This entry was posted in MFC and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>