| 网站首页 | JAVA文章 | AppServers | Web开发 | 应用开发 | 资源下载 | 论坛
    想学好编程,学好外语很重要  [enadd  2006年12月25日]        
设为首页 加入收藏 联系站长
您现在的位置: 编程笔记网 >> 应用开发 >> vc >> VC实例 >> 文章正文
明明白白看MFC之程序框架(二)        【字体:
明明白白看MFC之程序框架(二)
作者:-    文章来源:-    点击数:    更新时间:2006-4-20

二.MFC应用程序结构

  在《明明白白看MFC之程序框架(一)》中我分析了一个经典的应用程序的结构,现在可是要进入主题"MFC应用程序结构"了.应用程序有好多种,为了能够更清楚地与前面的文章形成对比,我们在这里看一个SDI的应用程序,当然例子还是经典的Hello World了。在使用向导生成应用程序后,会发现有好几个文件,首先我们不管有哪些文件,按照程序执行得主线抽取主要的源程序分析一下再说(因为 MFC 生成的应用程序不是很方便阅读,所以在这里我将他们重新编辑了)。

CHelloWorldApp theApp;

int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

LPTSTR lpCmdLine, int nCmdShow)

{

CWinThread* pThread = AfxGetThread();

CWinApp* pApp = AfxGetApp();

// AFX internal initialization

if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))

goto InitFailure;

// App global initializations (rare)

if (pApp != NULL && !pApp->InitApplication())

goto InitFailure;

// Perform specific initializations

if (!pThread->InitInstance())

{

if (pThread->m_pMainWnd != NULL)

{

TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");

pThread->m_pMainWnd->DestroyWindow();

}

nReturnCode = pThread->ExitInstance();

goto InitFailure;

}

nReturnCode = pThread->Run();

InitFailure:

……………………

AfxWinTerm();

return nReturnCode;

}

BOOL CWinApp::InitApplication()

{

if (CDocManager::pStaticDocManager != NULL)

{

if (m_pDocManager == NULL)

m_pDocManager = CDocManager::pStaticDocManager;

CDocManager::pStaticDocManager = NULL;

}

if (m_pDocManager != NULL)

m_pDocManager->AddDocTemplate(NULL);

else

CDocManager::bStaticInit = FALSE;

return TRUE;

}

BOOL CHelloWorldApp::InitInstance()

{

AfxEnableControlContainer();

………………………………

// Change the registry key under which our settings are stored.

// TODO: You should modify this string to be something appropriate

[1] [2] [3] 下一页  

文章录入:enadd    责任编辑:enadd 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
  • Windows网络编程经典入门

  • 制作自动循环播放的MP3播放器…

  • ping的源程序

  • 制作自动循环播放的MP3播放器…

  • 明明白白看MFC之程序框架(一…

  • 使用GDI在内存中转换图片类型

  • 扩展MFC类库建立自己的界面类…

  • 在BMP文件中隐藏信息(一)

  • VC下ADO开发实践之一

  • VC制作具有声音效果的动画桌…

  •   网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 管理登录 |