Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mixing MFC with WTL

370 views
Skip to first unread message

Tulio

unread,
May 18, 2007, 9:36:02 AM5/18/07
to
Hi,

I want to mix an MFC application with WTL but when I compile I get this error:

d:\WTL80_7108_Beta1\include\atluser.h(407) : error C2039: 'CString' : is not
a member of 'ATL'
d:\WTL80_7108_Beta1\include\atluser.h(561) : see reference to class
template instantiation 'WTL::CMenuT<t_bManaged>' being compiled
d:\WTL80_7108_Beta1\include\atlgdi.h(2573) : error C2039: 'CString' : is not
a member of 'ATL'
d:\WTL80_7108_Beta1\include\atlgdi.h(3284) : see reference to class
template instantiation 'WTL::CDCT<t_bManaged>' being compiled
d:\WTL80_7108_Beta1\include\atlgdi.h(2573) : error C2039: 'CString' : is not
a member of 'ATL'

Is it possible to mix MFC and WTL?

Thanks.

MrAsm

unread,
May 18, 2007, 10:16:13 AM5/18/07
to
On Fri, 18 May 2007 06:36:02 -0700, Tulio
<Tu...@discussions.microsoft.com> wrote:

>I want to mix an MFC application with WTL but when I compile I get this error:
>
>d:\WTL80_7108_Beta1\include\atluser.h(407) : error C2039: 'CString' : is not
>a member of 'ATL'

>Is it possible to mix MFC and WTL?

I believe it is.

In fact, WTL is built on top of ATL, and since VS2003, it seems that
MFC and ATL have been mixed together (in fact they share also some
classes like the new CString template - note that VS6 MFC CString was
not a template).

What compiler are you using? Maybe are you using an old compiler that
does not support modern WTL templates?

MrAsm

mosfet

unread,
May 18, 2007, 10:27:15 AM5/18/07
to
MrAsm a écrit :
Here is how I do it :

Declare this just after pragma once in stdafx:


#pragma once

#define _WTL_FORWARD_DECLARE_CSTRING
#define _WTL_NO_AUTOMATIC_NAMESPACE
//#define _WIN32_WCE_AYGSHELL 1
#include <atlbase.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlddx.h>
#include <atlctrls.h>
#include <atlctrlx.h>
#include <atlframe.h>
#include <atldlgs.h>
#include <atlscrl.h>
#include <atlmisc.h>

//#ifdef WIN32_PLATFORM_WFSP
//#include <tpcshell.h>
//#endif
//#include <atlwince.h>

//-----------------------------------------------------------------------------
// MFC STUFF
//-----------------------------------------------------------------------------

Tulio

unread,
May 18, 2007, 10:28:03 AM5/18/07
to
Hi,
I'm using VC++ .NET2003 and WTL 80_7180 Beta 1.

Mark Salsbery

unread,
May 18, 2007, 10:29:01 AM5/18/07
to
Maybe this article will help:

http://www.codeproject.com/wtl/mix_wtl_mfc.asp

Tulio

unread,
May 18, 2007, 10:36:02 AM5/18/07
to
I know this article. But I'm getting those errors before I use any WTL class.
Below is my stdafx.h file. The rest of project is just a plain Wizard
generated MFC application.

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to
the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different
platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and
Windows NT 4 or later.
#define WINVER 0x0400 // Change this to the appropriate value to target
Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or
later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to
target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or
later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to
target Windows Me or later.
#endif

#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400 // Change this to the appropriate value to target
IE 5.0 or later.
#endif

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will
be explicit

// turns off MFC's hiding of some common and often safely ignored warning
messages
#define _AFX_ALL_WARNINGS

#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes

#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <atlbase.h>
#include <atlstr.h>
#include <atlapp.h>

#include <shellapi.h>

#include <atlwin.h>

#include <atlframe.h>
#include <atlctrls.h>
#include <atlctrlx.h> // WTL enchanced common controls
#include <atldlgs.h>
#include <atlcrack.h> // WTL enhanced msg map macros
#include <atlcoll.h> // ATL collections
#include <atlddx.h> // WTL DDX support

#import "C:\\Arquivos de programas\\Arquivos comuns\\Microsoft
Shared\\Office11\\MSO.DLL" \
rename( "RGB", "MSORGB" )

using namespace Office;

#import "C:\\Arquivos de programas\\Arquivos comuns\\Microsoft
Shared\\VBA\\VBA6\\VBE6EXT.OLB"

using namespace VBIDE;

#import "C:\\Arquivos de programas\\Microsoft Office\\OFFICE11\\EXCEL.EXE" \
rename( "DialogBox", "ExcelDialogBox" ) \
rename( "RGB", "ExcelRGB" ) \
rename( "CopyFile", "ExcelCopyFile" ) \
rename( "ReplaceText", "ExcelReplaceText" )

ajk

unread,
May 18, 2007, 10:48:48 AM5/18/07
to
On Fri, 18 May 2007 07:28:03 -0700, Tulio
<Tu...@discussions.microsoft.com> wrote:

>Hi,
>I'm using VC++ .NET2003 and WTL 80_7180 Beta 1.

have you tried with WTL71? IIRC WTL75 was for VS2005 and WTL71 for
VS2003

mosfet

unread,
May 18, 2007, 10:58:23 AM5/18/07
to
You don't seem to read my post.

First check you use a recent WTL version (the last is 8)
then put this in your stdafx.h BEFORE MFC stuff. I insist on before!

#pragma once
//-----------------------------------------------------------------------------
// WTL STUFF
//-----------------------------------------------------------------------------
#define _WTL_FORWARD_DECLARE_CSTRING
#define _WTL_NO_AUTOMATIC_NAMESPACE

#include <atlbase.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlddx.h>
#include <atlctrls.h>
#include <atlctrlx.h>
#include <atlframe.h>
#include <atldlgs.h>
#include <atlscrl.h>
#include <atlmisc.h>

//-----------------------------------------------------------------------------
// MFC STUFF
//-----------------------------------------------------------------------------

//#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString
//constructors will
//be explicit

// turns off MFC's hiding of some common and often safely ignored warning
messages
#define _AFX_ALL_WARNINGS

#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes

#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common
Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <atlbase.h>
#include <atlstr.h>
#include <atlapp.h>

#include <shellapi.h>

#include <atlwin.h>


Tulio

unread,
May 18, 2007, 2:32:00 PM5/18/07
to
Hi mosftet,

I do as you suggested. Now I'm getting these error:

c:\Arquivos de programas\Microsoft Visual Studio .NET
2003\Vc7\atlmfc\include\afxv_w32.h(18) : fatal error C1189: #error :
WINDOWS.H already included. MFC apps must not #include <windows.h>

I must be missing something.

My stdafx.h file now looks like:

#pragma once

#define _WTL_FORWARD_DECLARE_CSTRING
#define _WTL_NO_AUTOMATIC_NAMESPACE
//#define _WIN32_WCE_AYGSHELL 1

#include <atlbase.h>
#include <atlapp.h>
#include <atlwin.h>
#include <atlddx.h>
#include <atlctrls.h>
#include <atlctrlx.h>
#include <atlframe.h>
#include <atldlgs.h>
#include <atlscrl.h>
#include <atlmisc.h>

#ifndef VC_EXTRALEAN


#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif

// turns off MFC's hiding of some common and often safely ignored warning
messages


#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes

#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

0 new messages