天天看點

win32中使用MFC類庫

能用, #include <afx.h>

在SDK程式中使用MFC中的輔助類

由于MFC中的輔助類,如CFileDialog,CFileFind,CString等使用起來非常的友善

如果用API來完成相應的工作,則需要自己完成大量的重複工作,使用MFC的輔助類

可以節省大量的開發時間,具體方法如下:

1.加入相應的頭檔案

由于在SDK程式中一定要包含windows.h頭檔案,是以在使用MFC中的類時,

如加入afx.h一類的頭檔案會有一個提示與windows.h相沖突,解決的辦法是,

去掉windows.h,然後在所有的.h檔案前加入

#include "stdafx.h"

#include <afxwin.h>        // MFC core and standard components

#include <afxext.h>        // MFC extensions

#include <afxdisp.h>        // MFC Automation classes

#include <afxdtctl.h>        // MFC support for Internet Explorer 4 Common Controls

#include <afxcmn.h>

注意一定要在所有的頭檔案之前加入這幾行,而且順序最好不要改變,否則會有大量的錯誤提示

2。 更改編譯設定

在Project->Setting->General 中選Use MFC in a Shared DLL或者 Use MFC in static Library

并把project->Setting->C/C++ 中的Use runing-time library 由Single-Threaded改為相應的

Multithreaded

簡單配置----增加工程選項 USING MFC 

繼續閱讀