How to Use the MFC class in a non-MFC program -- Solution # error: Windows. h already supported ded.

Source: Internet
Author: User

I want to use the cfiledialog class in the winproc function, so after # include <afxdlgs. h> is compiled, the following error occurs:

C:/program files/Microsoft Visual Studio/vc98/mfc/include/afxv_w32.h (14): Fatal error c1189: # error: Windows. h already included. MFC APPs must not # include <windows. h>

 

So, in the setting under the menu item project in the integration environment of vc6.0, I set the use of the MFC instance "use MFC in a shared DLL"

That is:

Project-> setting-> General-> Microsoft Foundation classed: Select use MFC in a shared DLL"

 

Add:

# Include <afxwin. h> // use MFC
# Include "afxdlgs. H" // use the cfiledialog class to include it

 

# Include "cv. H"
# Include "cxcore. H"
# Include "highgui. H"
# Include "stdafx. H"
# Include "resource. h"
# Include "commdlg. h"
# Include "direct. h"
# Include "stdio. h"
# Include "LbqSVM1.h"
# Include "HogOfImage. h"
# Include "Winbase. h"

 

# Include <afxwin. h>
# Include "afxdlgs. h"

 

The subsequent compilation error still exists, so change the order:

 

# Include <afxwin. h>
# Include "afxdlgs. h"

# Include "cv. h"
# Include "cxcore. h"
# Include "highgui. h"
# Include "stdafx. h"
# Include "resource. h"
# Include "commdlg. h"
# Include "direct. h"
# Include "stdio. h"
# Include "LbqSVM1.h"
# Include "HogOfImage. h"
# Include "Winbase. h"

 

Compiled!

 

Learn two points:

1. Choose project> setting> general> Microsoft Foundation Classed: Select Use MFC in a shared DLL.

2. # Changing the include sequence may solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.