本文整理汇总了C++中CWinApp::CloseAllDocuments方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::CloseAllDocuments方法的具体用法?C++ CWinApp::CloseAllDocuments怎么用?C++ CWinApp::CloseAllDocuments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::CloseAllDocuments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnEndSession
void CFrameWnd::OnEndSession( BOOL bEnding )
/******************************************/
{
if( bEnding ) {
CWinApp *pApp = AfxGetApp();
if( pApp != NULL && pApp->m_pMainWnd == this ) {
pApp->CloseAllDocuments( TRUE );
pApp->ExitInstance();
}
}
}
示例2: OnClose
void CFrameWnd::OnClose()
/***********************/
{
if( m_lpfnCloseProc != NULL ) {
m_lpfnCloseProc( this );
} else {
CWinApp *pApp = AfxGetApp();
if( pApp != NULL && pApp->m_pMainWnd == this ) {
if( !pApp->SaveAllModified() ) {
return;
}
pApp->CloseAllDocuments( FALSE );
if( pApp->m_pMainWnd == NULL ) {
// If the main window has been destroyed by CloseAllDocuments()
// (e.g. in an SDI application), just return since trying to execute the
// rest of OnClose() will cause a crash due to an invalid this pointer.
return;
}
}
CDocument *pDoc = GetActiveDocument();
if( pDoc != NULL ) {
if( !pDoc->CanCloseFrame( this ) ) {
return;
}
BOOL bOnlyFrame = TRUE;
POSITION position = pDoc->GetFirstViewPosition();
while( position != NULL ) {
CView *pView = pDoc->GetNextView( position );
ASSERT( pView != NULL );
if( pView->GetParentFrame() != this ) {
bOnlyFrame = FALSE;
break;
}
}
if( bOnlyFrame ) {
// OnCloseDocument destroys the frame, so just return after calling it.
pDoc->OnCloseDocument();
return;
}
pDoc->PreCloseFrame( this );
}
DestroyWindow();
}
}