gpt4 book ai didi

c++ - 除了使用 App Wizard 创建 MFC 应用程序之外,如何获得 MFC 支持?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:20:19 24 4
gpt4 key购买 nike

我知道当我们使用 App Wizard 在 VC++ 中创建 MFC 应用程序时,该向导会自动将所需的库添加到项目中。

我想手动创建一个 MFC 应用程序。如何做到这一点?

最佳答案

当您创建一个新的 MFC 应用程序时,您会在预编译头文件中找到这段代码:

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

这是如何包含 MFC 头文件的。即使您尝试创建一个新的 Win32 控制台应用程序并要求向导包含 MFC 支持,您仍会在预编译的 header 中再次找到这些行:

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

因此,如果您想创建一个只是以某种方式使用 MFC 类的控制台应用程序,那么只需创建一个新的空项目,转到其属性并在常规中更改MFC 的使用使用标准 Windows 库在静态库中使用 MFC。然后你只需要包含这些标题就可以了。 ;)

例子:

#include <iostream>
#include <afx.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions

int main()
{
CByteArray a;
a.Add(7);
std::cout << (int)a[0];
}

关于c++ - 除了使用 App Wizard 创建 MFC 应用程序之外,如何获得 MFC 支持?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10493855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com