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Ā ) ;