我想在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.0Integration Environment中的功能表項目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 順序調換可能會解決問題