///////////////////////////////////////////////////////////
// Replace the current view in the frame window pFrame
// by a new view of class pViewClass
// 1 - Find the currently active view
CView* pActiveView = pFrame->GetActiveView();
if( pActiveView == NULL )
{
TRACE0( "Unable to switch: no active view\n" );
return;
}
if( pActiveView->IsKindOf( pViewClass ) )
{
// No need to switch for same view class
return;
}
// 2 - Store current view position
CRect rcView;
pActiveView->GetWindowRect( &rcView );
// 4 - Make sure the document won't self-destruct
// when active view is destroyed
BOOL bSaveAutoDelete = pDoc->m_bAutoDelete;
pDoc->m_bAutoDelete = FALSE;
// 5 - Destroy the active view
pActiveView->DestroyWindow();
// 6 - Restore document to initial state
pDoc->m_bAutoDelete = bSaveAutoDelete;
// 7 - Initialize creation context used by CreateView
CCreateContext context;
context.m_pNewDocTemplate = NULL;
context.m_pLastView = NULL;
context.m_pCurrentFrame = NULL;