A project with ATL and MFC

Posted on 2005-04-27
Last Modified: 2013-11-25
I'm working on a project based on ATL (with Visual Studio.NET 2002), say project A. I need to add an existing project based on MFC (say project B) to the project A. Simply adding the new project Visual Studio compiles them with no errors. But when I try to include a .h file of project B in the project A, I get the error:

fatal error C1189: #error :  "CWnd class isn't included (include AFXWIN.H)"
(this error is in the .h file of project B included in a file of project A).

Then I include also afxwin.h in project A, but I get the error:

\afxv_w32.h(18): fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

I have done a lot of tries to solve the problem, but with no results.

Can someone help me?
Thank you in advance.


Question by:pappone
    LVL 9

    Expert Comment

    Simply adding a header file from one project to another will not necessarily enable you to exchange data or otherwise 'connect' the two projects. What is it that you're trying to achieve?


    Author Comment

    Hi Radu,
    the project A (based on ATL) is a framework with some edit windows; each window has a particular aim, one of these has to be a terminal for communicating through the serial port with an external device by AT commands. The project B provides some classes that wrap the windows API functions for serial communications. This project has been written for integrating it in a MFC project. Indeed, adding a header file from one project to another is only the first step for integrating project B in project A, but, unfortunately, this first step fails. You can find project B at: The project B is the project "Serial" in this site. The header file that I tried to add in project A is SerialMFC.h.

    Thank you very much for your comments.

    LVL 9

    Accepted Solution

    First thing to do is to add MFC support to your ATL project:;en-us;173974

    You will have to configure both projects A and B to link dynamically to MFC. Then, link A to B, also dynamically.


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now