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.