mfc >> WINDOWS.H already included. MFC apps must not #include <windows.h>

by Thomas Turner » Tue, 25 Apr 2006 16:25:51 GMT

Hi All

I getting an error message "WINDOWS.H already included. MFC apps must
not #include <windows.h>" However i not including windows.h anywhere in
my project.


Can you help

Many Thanks

Tom

Below is a copy of my stdafx.h



// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#if
!defined(AFX_STDAFX_H__6B703139_63DB_11D5_B5D1_4324324324822__INCLUDED_)
#define AFX_STDAFX_H__6B703139_63DB_11D5_B5D1_4324324324822__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000



#include <atlbase.h>
#if _ATL_VER >= 0x0700
#include <atlcoll.h>
#include <atlstr.h>
#include <atltypes.h>
#define _WTL_NO_CSTRING
#define _WTL_NO_WTYPES
#else
#define _WTL_USE_CSTRING
#endif

#include <atlapp.h>

extern CAppModule _Module;

#include <atlmisc.h>
#include <atlcom.h>
#include <atlhost.h>
#include <atlwin.h>
#include <atlctl.h>

#include <atlframe.h>
#include <atlctrls.h>
#include <atldlgs.h>
#include <atlctrlw.h>



#include "atlgdix.h"
#include "CustomTabCtrl.h"
#include "DotNetTabCtrl.h"
#include "SimpleTabCtrls.h"
//#include "SimpleDlgTabCtrls.h"
#include "TabbedFrame.h"
//#include "TabbedMDISave.h"
#include "ListViewNoFlicker.h"

#define _TABBEDMDI_MESSAGES_EXTERN_REGISTER
#define _TABBEDMDI_MESSAGES_NO_WARN_ATL_MIN_CRT
#include "TabbedMDI.h"

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





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

#include "Resource.h"
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxcview.h>
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common
Controls
#include <afxole.h>
#include <afxpriv.h>
#include <shlobj.h> // IShellFolder support
#include <afxmt.h>
#include <lm.h>
#include <afxtempl.h>



#include <afxdhtml.h>
#include <afxdlgs.h>



//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.

#endif //
!defined(AFX_STDAFX_H__6B703139_63DB_11D5_B5D1_4324324324822__INCLUDED_)



mfc >> WINDOWS.H already included. MFC apps must not #include <windows.h>

by Tim Ward » Tue, 25 Apr 2006 20:52:33 GMT






These are a right ****** to sort out, particularly when some of the code you
are building has to be portable to other platforms so some of the headers
you are including have not been written for MFC.

There's a compiler option that outputs a nested list of all the headers
included, that's essential information for trying to work out what's going
on.

The culprit may (after you've spent happy hours unravelling many levels of
includes) turn out to be some database header, or some tracing header, or
something else.





Similar Threads

1. #include <> and the INCLUDE environment var

Hi,

In now branching out to using directX, and wanting to include headers from 
it, I find myself wanting to setup VS so that I can just say:

#include <xact.h>

and thought that all I need do is add:

C:\Program Files\Microsoft DirectX SDK (April 2006)\Include

to the "Additional IncludeDirectories" under Config Properties / C/C++ / 
General on the property pages.

But, as this doesn't work, it would seem I need to setup an INCLUDE 
environment variable, or add this directory to it.

Is this the proper way to do this?  I really don't want to have to specify 
the path in my includes.

Thanks

2. #include "file" -vs- #include <file>

3. When to use #include <> and #include " "

My question is, if I have created my own library which lives in its own
install directory, to refer to its header file is it better to use

#include "MyLibrary.h"

or

#include <MyLibrary.h>

Assume that this library will be used by other groups. I think the answer
should be use the "<>" notation but I would be interested why.

cheers

Tuckers


4. Including MSDE in Windows package, containing C# app - .Net Framework