• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

A project with ATL and MFC

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.


  • 2
1 Solution
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?

papponeAuthor Commented:
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: http://www.codeproject.com/system/serial.asp. 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.

First thing to do is to add MFC support to your ATL project:

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now