Click to See Complete Forum and Search --> : MultiDocTemplate


37918
June 2nd, 1999, 10:17 AM
How do I open a new view without opening a new document. For example, two CFormViews on the same Document.

June 2nd, 1999, 11:59 AM
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 );

Dave Lorde
June 3rd, 1999, 04:00 AM
To do it manually, use CDocument::AddView(CView*).

Otherwise, create another CDocTemplate with the same document but a new view.

Dave