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

   我想在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 顺序调换可能会解决问题

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值