MFC中OnNewDocument与Serialize调用过程

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,用来保存文档模板的指针,即文档管器负责管理文档模板,而后者又是用来管理文档类、框架类和视类的,始终让这三个对象三位一体,一起为文档服务。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值