I like programming with WTL and ATL. It's straight forward, clean and quite frankly, simple. I've worked a little with attributed ATL projects and attributes make certain functions a lot simpler.
I needed to recode an ActiveX component recently to work around Vista's IE protected mode. I decided to work with attribtued ATL. Since several dialogs were involved, I decided to drag in WTL to simplify the dialog code. That's when the problems began.
I didn't know this, but attributed ATL projects drag in atlstr.h, via the header file atlplus.h. You need to define _WTL_NO_CSTRING before including atlmisc.h. Otherwise, your component will attempt to compile WTL::CString and ATL::CString. The results are "unpredictable", but generally not fun to resolve.
Here's a reference: WTL CString Class Implemented with the Standard C++ Library
I've reproduced the key items:
- WTL::CString is not compiled if you #define _WTL_NO_CSTRING before #include <atlmisc.h>
- You will get ATL::CString support if you #include <atlstr.h> before #include <atlapp.h>
- When ATL::CString is supported, WTL::CString should not be compiled.
- If rule 2 does not apply, you will get WTL::CString support for classes defined after #define _WTL_USE_CSTRING
- If rule 2 does not apply, you will get WTL::CString support for classes defined after #include <atlmisc.h>
Here's the order you need to use. Other headers should follow these four.
#define _WTL_NO_CSTRING
#include <atlbase.h>
#include <atlapp.h>
#include <atltypes.h>
#include <atlmisc.h>