欢迎来到天天文库
浏览记录
ID:22683574
大小:100.51 KB
页数:27页
时间:2018-10-30
《mfc视图结构框架分析》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、MFC文档视图结构框架分析1:程序的“导火索”---theAppCmyApptheApp;在声明对象的同时,调用其构造函数。按C++的语法,首先要调用其基类Cwinapp的构造函数.这个文件主要用于应用程序的一些初始化操作。classCWinApp:publicCWinThread{ DECLARE_DYNAMIC(CWinApp)public://Constructor CWinApp(LPCTSTRlpszAppName=NULL); …………} CWinApp::CWinApp(LPCTSTRlpszAppName){ if(lpszAppName!=NULL)
2、 m_pszAppName=_tcsdup(lpszAppName); else m_pszAppName=NULL; //initializeCWinThreadstate AFX_MODULE_STATE*pModuleState=_AFX_CMDTARGET_GETSTATE(); AFX_MODULE_THREAD_STATE*pThreadState=pModuleState->m_thread; ASSERT(AfxGetThread()==NULL); pThreadState->m_pCurrentWinThread=this; A
3、SSERT(AfxGetThread()==this); m_hThread=::GetCurrentThread(); m_nThreadID=::GetCurrentThreadId(); //initializeCWinAppstate ASSERT(afxCurrentWinApp==NULL);//onlyoneCWinAppobjectplease pModuleState->m_pCurrentWinApp=this; ASSERT(AfxGetApp()==this); //innon-runningstateuntilWinMain m_
4、hInstance=NULL; m_hLangResourceDLL=NULL; m_pszHelpFilePath=NULL; m_pszProfileName=NULL; m_pszRegistryKey=NULL; m_pszExeName=NULL; m_pRecentFileList=NULL; m_pDocManager=NULL; m_atomApp=m_atomSystemTopic=NULL; m_lpCmdLine=NULL; m_pCmdInfo=NULL; //initializewaitcursorstate m_
5、nWaitCursorCount=0; m_hcurWaitCursorRestore=NULL; //initializecurrentprinterstate m_hDevMode=NULL; m_hDevNames=NULL; m_nNumPreviewPages=0; //notspecified(defaultsto1) //initializeDAOstate m_lpfnDaoTerm=NULL; //willbesetifAfxDaoInitcalled //otherinitialization m_bHelpMode=FAL
6、SE; m_eHelpType=afxWinHelp; m_nSafetyPoolSize=512; //defaultsize}2:theApp之后的隐藏代码,由他控制整个程序的流程。_tWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance, LPTSTRlpCmdLine,intnCmdShow){ //callshared/exportedWinMain returnAfxWinMain(hInstance,hPrevInstance,lpCmdLine,nCmdShow);} 其中有宏定义:#defin
7、e_tWinMain wWinMain intAFXAPIAfxWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance, LPTSTRlpCmdLine,intnCmdShow){ ASSERT(hPrevInstance==NULL); intnReturnCode=-1; CWinThread*pThread=AfxGetThread();;//CWinApp是从CW
此文档下载收益归作者所有