单文档对话框:.基于对话框(/单文档/多...

. 基于对话框(/文档/多文档)的MFC程序#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
stdafx.h预编译头文件
afxext.h声明MFC一些扩展类(CBitmapButton、CControlBar、CSplitterWnd等)
afxdisp.h中声明了Ole的几个类(COleException、COleVariant等)
afxwin.h声明MFC封装的一些很基本的类(CWnd、CView、CButton、CDC等)afxdtctl.h声明几个控件类(CImageList、CMonthCalCtrl、CDateTimeCtrl等)Controls
afxcmn.h声明MFC一些控件(CListCtrl、CProgressCtrl、CToolTipCtrl等)
#include <afxcmn.h> // MFC support for Windows Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#endif // _AFX_NO_AFXCMN_SUPPORT
(1.1)Use MFC in a Shared DLL
Debug版本:
预定义:WIN32,_DEBUG,_WINDOWS,_AFXDLL,_MBCS
编译参数:/nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"Debug/" /Fp"Debug/ExeDlg.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
连接参数:/nologo /subsystem:windows /incremental:yes /pdb:"Debug/ExeDlg.pdb" /debug /machine:I386 /out:"Debug/ExeDlg.exe" /pdbtype:sept
Release版本:
预定义:与Debug版本相比,将_DEBUG替换成了NDEBUG
编译参数:/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"Release/ExeDlg.pch" /Yu"stdafx.h" /Fo"Release/" /Fd"Release/" /FD /c
连接参数:/nologo /subsystem:windows /incremental:no /pdb:"Release/ExeDlg.pdb" /machine:I386 /out:"Release/ExeDlg.exe"
(1.2)Use MFC in a Static Library
Debug版本:
预定义:与(1.1)相比,少了_AFXDLL
编译参数:将/MDd(使用Run-time library: Debug Multithreaded DLL)换成了/MTd(使用Run-time library: Debug Multithreaded)
连接参数:与(1.1)相同
Release版本:
编译参数/MD(使用Run-time library: Multithreaded DLL)换成了MT(使用Run-time library: Multithreaded)
***备注:以上编译/连接参数含义如下(更多的,请参考Msdn):
/nologo:抑制信息在编译或者连接时在Output Window输出; /MD:运行时库使用MSVCRT.DLL; /W3:编译时显示为Warning的级别为3; /Gm:Enable Minimal Rebuild,一种减少重编译的选项; /GX:Enable Exception Handling; /ZI:设置Debug信息保存的数据库文件.PDB中; /Od:Disable代码优化; /FR:生成.SBR文件,包含有符号信息; /Fp:命名生成的预编译头文件; /Yu:指定预编译头文件。
2.MFC DLL
预编译头文件stdafx.h:
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h> // MFC OLE classes
#include <afxodlgs.h> // MFC OLE dialog classes
#include <afxdisp.h> // MFC Automation classes
#endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h> // MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h> // MFC DAO database classes
#endif // _AFX_NO_DAO_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
增加了两个OLE的头文件和两个数据库的头文件
(2.1) Use MFC in a Shared DLL
Debug版本:
预定义:WIN32,_DEBUG,_WINDOWS,_WINDLL,_AFXDLL,_MBCS,_USRDLL,与MFC Exe程序相比,增加了_WINDLL和_USRDLL
编译参数:与MFC Exe没有太大区别
连接参数:/nologo /subsystem:windows /dll /incremental:yes /pdb:"Debug/MFCDll.pdb" /debug /machine:I386 /def:".\MFCDll.def" /out:"Debug/MFCDll.dll" /implib:"Debug/MFCDll.lib" /pdbtype:sept
与MFC Exe相比,增加了/dll定义,以及/def:".\MFCDll.def"和/implib:"Debug/MFCDll.lib"。注意:其中MFCDll是测试的项目名字,非标准DLL名字。从项目的文件上看,这个项目比MFC Exe多产生一个.def的文件用于定义导出函数。Release版本与Debug版本的区别类似项目1中的比较(上了_AFXDLL定义)。
(2.2) Use MFC in a Static DLL
与(2.1)的区别,主要在使用的Run-time library类型上,与项目1中的比较。
3.MFC Extension DLL
预编译头文件stdafx.h内容与项目2相同。
(3.1) Use MFC in a Shared DLL
Debug版本:
预定义:WIN32,_DEBUG,_WINDOWS,_MBCS,_AFXEXT,_WINDLL,_AFXDLL,与项目2相比,将_USRDLL换成了_AFXEXT。
编译参数:与上述项目没有太大区别
连接参数:与MFC DLL项目相似
Release版本与Debug版本的区别类似项目1中的比较(上了_AFXDLL定义)。
(3.2) Use MFC in a Static DLL
类似以上项目的比较。
(注:以下项目均以Debug版本论述。)
4.Win32 DLL
预编译头文件stdafx.h:
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include <windows.h>
出现项目入口函数DllMain的实现。
(4.1) Not Using MFC
预定义:WIN32,_DEBUG,_WINDOWS,_MBCS,_USRDLL,WIN32DLLDEMO_EXPORTS,与项目2(MFC DLL)相比,少了_WINDLL,_AFXDLL,而仅保留了_USRDLL。另外,WIN32DLLDEMO_EXPORTS自定义的导出宏。
编译参数:没有太大区别。
连接参数:kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"Debug/Win32DllDemo.pdb" /debug /machine:I386 /out:"Debug/Win32DllDemo.dll" /implib:"Debug/Win32DllDemo.lib" /pdbtype:sept
与MFC DLL项目相比,多了很多库的连接,少了/sub
Tags:  mfc基于对话框 单文档多文档 多页对话框 单文档对话框

延伸阅读

最新评论

发表评论