How do I open a new view without opening a new document. For example, two CFormViews on the same Document.
Printable View
How do I open a new view without opening a new document. For example, two CFormViews on the same Document.
try something like this from a message handler in the document:
CMDIChildWnd *pActiveChild = ((CMDIFrameWnd*)AfxGetApp()->m_pMainWnd)->MDIGetActive();
if ( pActiveChild == NULL )
return;
CMyTemplate *pTemplate = ((CMyApp *)AfxGetApp())->MyTemplate();
CRuntimeClass *pOldView = pTemplate->SetView( RUNTIME_CLASS( CAnotherView ) );
UINT nOldID = pTemplate->SetID( IDR_GRIDVIEW );
ASSERT_VALID(pTemplate);
CFrameWnd *pFrame = pTemplate->CreateNewFrame( this, pActiveChild );
ASSERT( pFrame );
if ( pFrame == NULL )
return;
pTemplate->InitialUpdateFrame( pFrame, this );
To do it manually, use CDocument::AddView(CView*).
Otherwise, create another CDocTemplate with the same document but a new view.
Dave