本文整理汇总了C++中CDocument::OnCloseDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ CDocument::OnCloseDocument方法的具体用法?C++ CDocument::OnCloseDocument怎么用?C++ CDocument::OnCloseDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDocument
的用法示例。
在下文中一共展示了CDocument::OnCloseDocument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CloseAllDocuments
void CDocTemplate::CloseAllDocuments(BOOL)
{
POSITION pos = GetFirstDocPosition();
while (pos != NULL)
{
CDocument* pDoc = GetNextDoc(pos);
pDoc->OnCloseDocument();
}
}
示例2: CloseSkinFile
BOOL CFileView::CloseSkinFile(CString& strPath)
{
CDocument* pDoc = FindSkinFile(strPath);
if(pDoc == NULL)
return FALSE;
pDoc->OnCloseDocument();
return TRUE;
}
示例3: 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();
}
}
示例4: OnScriptMakeModel
void CScriptView::OnScriptMakeModel()
{
// First we save script file
CModelerDoc *pDoc = (CModelerDoc *) GetDocument();
CTFileName fnScriptName = CTString(pDoc->GetPathName());
CTFileName fnModelName = fnScriptName.FileDir() + fnScriptName.FileName() + ".mdl";
try
{
fnScriptName.RemoveApplicationPath_t();
}
catch( char *err_str)
{
AfxMessageBox( err_str);
return;
}
pDoc->OnSaveDocument( pDoc->GetPathName());
// close mdl document with same name
POSITION pos = theApp.m_pdtModelDocTemplate->GetFirstDocPosition();
while (pos!=NULL)
{
CModelerDoc *pmdCurrent = (CModelerDoc *)theApp.m_pdtModelDocTemplate->GetNextDoc(pos);
if( CTFileName( CTString(pmdCurrent->GetPathName())) == fnModelName)
{
pmdCurrent->OnCloseDocument();
break;
}
}
// Now we will create one instance of new document of type CModelerDoc
CDocument* pDocument = theApp.m_pdtModelDocTemplate->CreateNewDocument();
if (pDocument == NULL)
{
TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
return;
}
ASSERT_VALID(pDocument);
BOOL bAutoDelete = pDocument->m_bAutoDelete;
pDocument->m_bAutoDelete = FALSE; // don't destroy if something goes wrong
CFrameWnd* pFrame = theApp.m_pdtModelDocTemplate->CreateNewFrame(pDocument, NULL);
pDocument->m_bAutoDelete = bAutoDelete;
if (pFrame == NULL)
{
AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
delete pDocument; // explicit delete on error
return;
}
ASSERT_VALID(pFrame);
pDocument->SetPathName( fnModelName, FALSE);
pDocument->SetTitle( fnModelName.FileName() + fnModelName.FileExt());
char strError[ 256];
if( !((CModelerDoc *)pDocument)->CreateModelFromScriptFile( fnScriptName, strError))
{
pDocument->OnCloseDocument();
AfxMessageBox( strError);
return;
}
theApp.m_pdtModelDocTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE);
((CModelerDoc *)pDocument)->m_emEditModel.edm_md.md_bPreparedForRendering = FALSE;
pDocument->SetModifiedFlag();
// add textures from .ini file
CTFileName fnIniFileName = fnScriptName.NoExt() + ".ini";
try
{
((CModelerDoc *)pDocument)->m_emEditModel.CSerial::Load_t(fnIniFileName);
}
catch( char *strError)
{
// ignore errors
(void) strError;
}
}