这个方法是CreateNewFrame,呵呵CCreateContext context;
context.m_pCurrentFrame = pOther;//Current frame.
context.m_pCurrentDoc = (CDocument *)pDoc;
//m_pDocTemplate;
context.m_pNewDocTemplate = NULL;CRuntimeClass *pViewClass;
pViewClass = RUNTIME_CLASS(CMyFormView);
context.m_pNewViewClass = pViewClass;//create childframe for this view
CRuntimeClass *pFrameClass = RUNTIME_CLASS(CMyChildFrame);CFrameWnd* pFrame = (CFrameWnd*)pFrameClass->CreateObject();
CFrameWnd * pMainWnd = (CFrameWnd *)AfxGetMainWnd();
if (!pFrame->LoadFrame(IDR_DSSCFTYPE,WS_OVERLAPPEDWINDOW ¦ FWS_ADDTOTITLE, NULL, &context))
{
TRACE0("Warning: CDocTemplate couldn't create a frame.\n");
// frame will be deleted in PostNcDestroy cleanup
return NULL;
}关键在pViewClass = RUNTIME_CLASS(CMyFormView);这一句,你可以修改来创建不同的View。这个放个Switch也可以(如果你的View有3个以上,应该就是这样的了。)