您的位置:首页 > 其它

如何在非MFC程序中使用MFC类——解决#error : WINDOWS.H already included.

2009-03-20 09:43 453 查看
我想在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 顺序调换可能会解决问题
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐