Tuesday, May 21, 2013

What is 'CPoint' : ambiguous symbol atltypes.h?

It was a dark and rainy night.. I was trying to do something useful.. what I don't remember right now.. But I was getting this weird problem...

Error 1 error C2872: 'CPoint' : ambiguous symbol atltypes.h
Error 2 error C2872: 'CRect' : ambiguous symbol atltypes.h
Error 3 error C2872: 'CSize' : ambiguous symbol atltypes.h
.
.
Error N error C2872: 'CReality' : ambiguous symbol life.h

Obviously (is it?) I was using ATL and WTL to do something... After scratching my head, googling and going through few WTL headers .. I found the solution. Just include the following, just after you add the #include <windows.h> :
#include <atlbase.h>

#if (_ATL_VER >= 0x0700)
#include <atlstr.h>
#include <atltypes.h>
#endif

#if (_ATL_VER >= 0x0700)
#define _WTL_NO_CSTRING
#define _WTL_NO_WTYPES
#define _WTL_NO_UNION_CLASSES
#endif

#include <atlapp.h>

Sunday, May 12, 2013

WTL::CRichEditCtrl

WTL::CRichEditCtrl needs the following line for initialization, add it in your DllMain or _tWinMain and it resolves the issue:
HINSTANCE hInstRich = ::LoadLibrary(CRichEditCtrl::GetLibraryName());
Unfortunately I forgot that Rich Edit isn’t a common control and is not initialized with InitCommonControlsEx.