我想在WinProc函数中使用CFileDialog类,于是#include <afxdlgs.h>以后编译,出现了以下错误:
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>
于是, 我在VC6.0集成环境中的菜单项project下的setting中设置使用MFC例"use mfc in a shared DLL"
即:
project->setting->general->Microsoft Foundation Classed: 选择 Use MFC in a shared DLL"
同时,加入:
#include <afxwin.h>//使用MFC
#include "afxdlgs.h"//使用CFileDialog类需要包含它
#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"
后编译错误依然存在,于是把顺序调换一下:
#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"
编译通过!
学会两点:
1、在project->setting->general->Microsoft Foundation Classed: 选择 Use MFC in a shared DLL
2、#include 顺序调换可能会解决问题