- 1
- 0
- 约1.9万字
- 约 30页
- 2022-10-16 发布于山东
- 举报
精品文档
MFC文档视图构造框架解析
1:程序的“导火索”theApp
CmyApptheApp;
在声明象的同,用其构造函数。按C++的法,首先要用其基Cwinapp的
构造函数.个文件主要用于用程序的一些初始化操作。
classCWinApp:publicCWinThread
{
DECLARE_DYNAMIC(CWinApp)
public:
//Constructor
CWinApp(LPCTSTRlpszAppName=NULL);
????
}
CWinApp::CWinApp(LPCTSTRlpszAppName)
{
if(lpszAppName!=NULL)
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;
ASSERT(AfxGetThread( )==this);
m_hThread=::GetCurrentThread( );
m_nThreadID=::GetCurrentThreadId( );
精品文档
精品文档
//initializeCWinAppstate
ASSERT(afxCurrentWinApp==NULL);//onlyoneCWinAppobjectplease
pModuleState-m_pCurrentWinApp=this;
ASSERT(AfxGetApp( )==this);
innon-runningstateuntilWinMainm_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;
initializewaitcursorstatem_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=FALSE;
m_eHelpType=afxWinHelp;
m_nSafetyPoolSize=512;//defaultsize
}
精品文档
精品文档
2:theApp之后的隐藏代码,由他控制整个程序的流程。
_tWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,
LPTSTRlpCmdLine,intnCmdShow)
{
//callshared/exportedWinMain
returnAfxWinMain(hInstance,hPrevInstance,lpCmdLine,nCmdShow);
}
其中有宏定义:#define_tWinMainwWinMain
intAFXAPIAfxWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,
LPTSTRlpCmdLine,intnCmdShow)
{
ASSERT(hPrevInstance==NULL);
intnReturnCode=-1;
CWinThread*pThread=AfxGetThread( );;//CWinApp是从CWinThread派
生的,
CWinApp*pApp=AfxGetApp( );//实质上就是pThread==pApp
//AFXinternalinitialization
if(!AfxWinInit(hInstance,hPrevInstance,lpCmdLine,n
您可能关注的文档
最近下载
- 陶行知教育文集读后感.pdf VIP
- 2025年广东省住院医师规范化培训结业理论考核(外科)历年参考题库含答案详解.docx VIP
- 河道管理工程施工的重点及难点攻克策略.docx VIP
- 2025学年小学综合实践活动二年级下册全册教案.docx VIP
- 心房颤动管理指南(2026年版).pptx VIP
- 2026年猫宁供应商入驻考试答案及题目.docx
- WC67Y—100T使用说明书内容.pdf VIP
- 2026版高考物理南方凤凰台二轮复习主观题限时热练5(学用).doc VIP
- 考虑停车容量约束的瓶颈路段通勤出行拥挤收费研究-交通运输规划与管理专业毕业论文.docx VIP
- 2025年江西外语外贸职业学院单招职业适应性测试题库附参考答案(考试直接用).docx VIP
原创力文档

文档评论(0)