解决不能从 WTL::CString 转换为 ATL::CSimpleString & 的问题

WTL提供的CString类在ATL中也提供了相同的类后变得有点鸡肋,并且使用WTL::CString类后,经常会出现标题所示的编译错误。实际上ATL不仅在<atlstr.h>中提供了CString类,还在<atltypes.h>中提供了CPoint、CSize和CRect类,因此,WTL中提供的同名类变得可有可无。我认为还是用ATL中的类会好一些,毕竟WTL没有文档嘛。

因此,应该在工程头文件中包含任何WTL头文件前定义以下两行:

#define _WTL_NO_CSTRING
#define _WTL_NO_WTYPES

典型的声明顺序应该这样:

#include <atlbase.h>
#include <atlstr.h>
#include <atltypes.h>
#include <atlapp.h>
extern CAppModule _Module;
#include <atlwin.h>
#include <atlcrack.h>
#include <atlsplit.h>
#include <atlframe.h>
#include <atlgdi.h>
#include <atlctrls.h>
#include <atlctrlx.h>
#include <atlmisc.h>
#include <......等等>

网上搜索,已无出处可考

原文地址:https://www.cnblogs.com/guobbs/p/3665592.html