[visual-c++] afxwin.h file is missing in VC++ Express Edition

When I try to run the file VC++ 2005 to VC++ 2008:

1>------ Build started: Project: canvas, Configuration: Debug Win32 ------  
1>Compiling...  
1>canvasApp.cpp  
1>c:\documents and settings\ram\my documents\visual studio 2008\demo\stdafx.h(1) : fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory  
1>canvasFrame.cpp  
1>c:\documents and settings\ram\my documents\visual studio 2008\demo\stdafx.h(1) : fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory  
1>Generating Code...  
1>Build log was saved at "file://c:\Documents and Settings\ram\My Documents\Visual Studio 2008\demo\Debug\BuildLog.htm"  
1>canvas - 2 error(s), 0 warning(s)  
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========  

This question is related to visual-c++

The answer is


Including the header afxwin.h signalizes use of MFC. The following instructions (based on those on CodeProject.com) could help to get MFC code compiling:

  1. Download and install the Windows Driver Kit.

  2. Select menu Tools > Options… > Projects and Solutions > VC++ Directories.

  3. In the drop-down menu Show directories for select Include files.

  4. Add the following paths (replace $(WDK_directory) with the directory where you installed Windows Driver Kit in the first step):

    $(WDK_directory)\inc\mfc42
    $(WDK_directory)\inc\atl30
    

  5. In the drop-down menu Show directories for select Library files and add (replace $(WDK_directory) like before):

    $(WDK_directory)\lib\mfc\i386
    $(WDK_directory)\lib\atl\i386
    

  6. In the $(WDK_directory)\inc\mfc42\afxwin.inl file, edit the following lines (starting from 1033):

    _AFXWIN_INLINE CMenu::operator==(const CMenu& menu) const
        { return ((HMENU) menu) == m_hMenu; }
    _AFXWIN_INLINE CMenu::operator!=(const CMenu& menu) const
        { return ((HMENU) menu) != m_hMenu; }
    

    to

    _AFXWIN_INLINE BOOL CMenu::operator==(const CMenu& menu) const
        { return ((HMENU) menu) == m_hMenu; }
    _AFXWIN_INLINE BOOL CMenu::operator!=(const CMenu& menu) const
        { return ((HMENU) menu) != m_hMenu; }
    

    In other words, add BOOL after _AFXWIN_INLINE.


I encountered the same problem. The easiest thing is to install the free Visual Studio Community 2015 as answered in this question Is MFC only available with Visual Studio, and not Visual C++ Express?


I see the question is about Express Edition, but this topic is easy to pop up in Google Search, and doesn't have a solution for other editions.

So. If you run into this problem with any VS Edition except Express, you can rerun installation and include MFC files.