1. OnNewDocument()调用过程:
程序启动->CWinApp:;OnFileNew(m_pDocManager->OnFileNew()) ->CDocManager::OnFileNew(pTemplate->OpenDocumentFile(NULL)) ->CSingleDocTemplate::OpenDocumentFile(CreateNewDocument->CreateNewFrame pDocument->OnNewDocument) -> CGraphicDoc::OnNewDocument
2.Serialize()调用过程
文件打开菜单命令->CWinApp::OnFileOpen(m_pDocManager->OnFileOpen()) ->CDocManager::OnFileOpen(调用DoPromptFileName函数显示文件打开对话框->AfxGetApp()->OpenDocumentFile) ->CWinApp::OpenDocumentFile(m_pDocManager->OpenDocumentFile) ->CDocManager::OpenDocumentFile ->CSingleDocTemplate::OpenDocumentFile(pDocument->OnOpenDocument) ->CDocument::OpenDocument(构造一个CFile::modeRead模式的Cfile对象-》构造一个CArchive::load模式的CArchive对象-》Serialize(loadArchive))->CGraphicDoc::Serialize
[文件\新建]和【文件\打开】菜单项的命令响应函数都是在CWinApp类中提供的。CWinApp类有一个成员变量:m_pDocManager,是指向CDocManager对象的指针,也就是说,CWinApp负责管理文档管理器,而后者有一个文档模板指针链表:m_templateList,用来保存文档模板的指针,即文档管器负责管理文档模板,而后者又是用来管理文档类、框架类和视类的,始终让这三个对象三位一体,一起为文档服务。