MFC程序引导过程(二)
来源:互联网 发布:js apply原理 编辑:程序博客网 时间:2024/06/14 22:45
<pre name="code" class="cpp"><pre name="code" class="cpp">// 333.cpp : Defines the class behaviors for the application.//#include "stdafx.h"#include "333.h"#include "333Dlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// CMy333AppBEGIN_MESSAGE_MAP(CMy333App, CWinApp)//{{AFX_MSG_MAP(CMy333App)// NOTE - the ClassWizard will add and remove mapping macros here.// DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSGON_COMMAND(ID_HELP, CWinApp::OnHelp)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CMy333App constructionCMy333App::CMy333App(){// TODO: add construction code here,// Place all significant initialization in InitInstance}/////////////////////////////////////////////////////////////////////////////// The one and only CMy333App objectCWinApp?CMy333App theApp;第一步:实例化应用程序类的对象(CWinApp),在当前程序的333.h文件中有:class CMy333App : public CWinApp1.一个MFC程序,有且只有一个从WinApp派生出的类(应用程序类)-》CMy333App?,也只有一个从应用程序对象所实例化的对象表示应用程序本身,theApp;2.在MFC应用程序中,是通过产生一个应用程序对象,用它来唯一表示了应用程序;3.构造应用程序对象时,调用基类CWinApp的构造函数/////////////////////////////////////////////////////////////////////////////// CMy333App initializationBOOL CMy333App::InitInstance()第二步:调用应用程序类中的InitInstance()函数,该函数在基类中定义为虚函数{if (!AfxSocketInit()){AfxMessageBox(IDP_SOCKETS_INIT_FAILED);return FALSE;}AfxEnableControlContainer();// Standard initialization// If you are not using these features and wish to reduce the size// of your final executable, you should remove from the following// the specific initialization routines you do not need.#ifdef _AFXDLLEnable3dControls();// Call this when using MFC in a shared DLL#elseEnable3dControlsStatic();// Call this when linking to MFC statically#endifCMy333Dlg dlg;第三步:定义主对话框类的对象dlg;并且调用对话框类的构造函数CMy333Dlg(CWnd *pParent=Null);注:333Dlg.h的头文件中有class CMy333Dlg : public CDialogm_pMainWnd = &dlg;int nResponse = dlg.DoModal();第四步:调用主对话框对象的DoModal()函数,??||—>a.调用主对话框对象中的OnInitDialog()函数初始化对话框| OnInitDialog()是CDialog类的一个虚函数,可以由子类重载。| 当CDiaog子类调用DoModal()函数时,就会触发一系列函数调用,| 最终调用OnInitDialog()。可以在VC6中创建一个基于对话框的MFC应用程序,| 在OnInitDialog里面打上断点,当程序运行进入断点是,打开调用堆栈窗口,| 就可以跟踪得到调用OnInitDialog()的函数。||—>b.调用OnPaint()函数,绘制窗口第五步:对话框退出后,返回DoModel()函数状态给nResponseif (nResponse == IDOK){// TODO: Place code here to handle when the dialog is// dismissed with OK}else if (nResponse == IDCANCEL){// TODO: Place code here to handle when the dialog is// dismissed with Cancel}// Since the dialog has been closed, return FALSE so that we exit the// application, rather than start the application's message pump.return FALSE;}
</pre>
0 0
- MFC程序引导过程(二)
- linux引导程序剖析(二)
- MFC启动过程(二)
- 自制能使用U盘引导的程序(二)
- Bootleader引导程序——u-boot(二)
- MFC程序启动过程
- MFC程序启动过程
- MFC--程序执行过程
- MFC 程序运行过程
- MFC程序执行过程
- mfc程序运行过程
- MFC打字训练娱乐程序(二)
- MFC截图程序的实现(二)
- bootm引导内核过程详解之二
- 中断19引导加载程序过程详解
- MFC程序的初始化过程
- MFC程序的诞生过程
- MFC程序运行过程梳理
- HDU 2063 过山车 匈牙利算法模板题
- html基础试题
- 如何查看电脑最全详细信息
- iOS小项目-使用Slider完成三种颜色的改变
- mina源码分析---4
- MFC程序引导过程(二)
- ACE中ACE_SOCK下ACE_SOCK_Acceptor类解析
- pthread_cond_signal虚假唤醒(spurious wakeup)
- MYSQL数据库乱码解决方案
- Linux gcc,gdb命令及vim配置
- Objective-C中对IPhone设备震动的调用
- python 基本知识学习
- JAVA 集合框架
- linux 命令及shell 知识小点汇集