建工程的时候一定要选上 No enhanced MFC controls.
如果是从以前版本的工程升级到 2015 的,在 stdafx.h 头文件中加上:
#define _AFX_NO_MFC_CONTROLS_IN_DIALOGS
如果建工程的时候没选 No enhanced MFC controls. 之后的修改方法为:
1. stdafx.h 中加上 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS
2. 在 工程名.rc 文件中去掉 #include "afxribbon.rc" // MFC ribbon and control bar resources
› 网友 adie () 于 2016-12-28 16:05:52 发表评论说:
链接时出现错误:
>uafxcwd.lib(afxctrlcontainer2.obj) : error LNK2005: "void __cdecl AfxRegisterMFCCtrlClasses(void)" (?AfxRegisterMFCCtrlClasses@@YAXXZ) already defined in afxnmcdd.lib(afxctrlcontainer2.obj)
1>uafxcwd.lib(afxctrlcontainer2.obj) : error LNK2005: "protected: void __cdecl CMFCControlContainer::PreUnsubclassControl(class CWnd *)" (?PreUnsubclassControl@CMFCControlContainer@@IEAAXPEAVCWnd@@@Z) already defined in afxnmcdd.lib(afxctrlcontainer2.obj)
1>uafxcwd.lib(afxctrlcontainer2.obj) : error LNK2005: "public: int __cdecl CMFCControlContainer::SubclassDlgControls(void)" (?SubclassDlgControls@CMFCControlContainer@@QEAAHXZ) already defined in afxnmcdd.lib(afxctrlcontainer2.obj)
1>E:\work\yproject\DbgTools\x64\Debug\MemoryWalker.exe : fatal error LNK1169: one or more multiply defined symbols found
还需要删除和工程同名的 cpp 文件中的
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
和
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}