How to add MFC Common class into your application based on SDK?
来源:互联网 发布:sqlserver安装polybase 编辑:程序博客网 时间:2024/05/18 19:36
Recently, I meet a request that modify a DLL based on SDK to support MFC common class.It seems a easy task, but I meet a great difficult. So I have a idea of writing something to record my experience and hope others can benefit from it.
For there are some common class like CFileDialog,CFileFind,CString which provide a easy way to suit your needs.otherwise you would need multi-effort If you implement by API .Using MFC can save a lot of time. Following is the steps:
1. add Related Header file.
For Application based on SDK need include “windows.h”, When you uing MFC common class , adding “afx.h”would result in conflicting with “windows.h”. The way to solve it is removing “windows.h”,after that add #include “stdafx.h”in front of all “.H”header file.
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#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
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#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
Notes: above code must be added in front all head file and its order cann’t change, or it occurs some compile errors.
2. Modify compile setting.
Open Project->Setting->General, select Use MFC in a Shared DLL or Use MFC in static Library,and change Use runing-time library From Single-Threaded to Multithreaded From project->Setting->C/C++.
2. Modify compile setting.
Open Project->Setting->General, select Use MFC in a Shared DLL or Use MFC in static Library,and change Use runing-time library From Single-Threaded to Multithreaded From project->Setting->C/C++.
After above modification, I re-compile project, there occurs a error: error LNK2005: _DllMain@12 already defined in OCRDLL.obj. Don’t worry , you should only remove _USRDLL from preprocessor definitions seetings.
OK. You have successfully modify a sdk application to support MFC common class!
- How to add MFC Common class into your application based on SDK?
- How to add local jar into your local maven repository
- How To Add Breakpad To Your Linux Application
- How to build your GTK+ application on Windows
- How to add a Custom Pull to Refresh in your iOS Application
- How to config your SDK
- How to Add Perl CGI Script Support to Your Apache Server on Windows
- How to Add Perl CGI Script Support to Your Apache Web Server on Windows
- how to build your web application on spring boot and deploy it on heroku
- How To Use MySQL with Your Ruby on Rails Application on Ubuntu 14.04
- How to SSH Into Your iPhone
- How to add SMSC feature into Android
- How to add project into Android BSP
- How to add OLE drag-and-drop functionality to a pre-existing MFC application
- Add crash report to your application (windbg)
- How to add CoverFlow Effect on your iPhone App – OpenFlow
- How to import Ocx into MFC project
- How to get sudo on Your ubuntu
- 用PHP控制您的浏览器cache
- 窗体.show竟然无效
- 在Linux下快速搭建LAMP开发平台
- 实战SSL安全加密机制
- Remoting技术初探--实现简单服务器客户机通信
- How to add MFC Common class into your application based on SDK?
- Oreilly好书征集译者!
- 故宫一游
- AJAX读取XML赋值给下拉列表
- SELinux和maxent
- 对widget(挂件技术)的一点看法
- javascript code all (2) (转转)
- Windows Shell 编程 第四章
- java.io包