描述:
请问:在代码里怎么人工添加 MFC的支持,谢谢
解决方案1:
search msdn:
HOWTO: Add MFC Support to an ATL Project
Adding MFC Support to an ATL DLL Project
Follow steps 1 to 3 from above.
Move the code in the AppWizard-generated DllMain's DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH to the CMyApp's InitInstance and ExitInstance and remove the DllMain as follows:
BOOL CMyApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance);
return CWinApp::InitInstance();
}
int CMyApp::ExitInstance()
{
// MFC's class factories registration is
// automatically revoked by MFC itself.
if (m_bRun)
_Module.RevokeClassObjects();
Add the following line of code to the beginning of every member function of a COM interface, window procedure and exported function:
AFX_MANAGE_STATE(AfxGetStaticModuleState());
For additional information, please see the following article in the Microsoft Knowledge Base:
Q140850 HOWTO: Converting DLLTRACE to Use MFC in Shared Library
NOTE: For all release builds, make sure that the _ATL_MIN_CRT preprocessor definition has been removed. You can find these definitions in the Preprocessor category of the C/C++ tab in the Project Settings dialog box.
When adding a class derived from a MFC class using the ClassWizard to an ATL EXE project or to an ATL DLL project without "MFC Support," the compiler will issue a C2504 error.
#include <afxwin.h>
#include <afxdisp.h>