c++ - hwnd 是 winuser.h 的 udefined c++ 导入
问题描述
#include "stdafx.h"
#include <winuser.h>
#include <iostream>
#define WIN32_LEAN_AND_MEAN
using namespace std;
typedef struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;
int main()
{
RECT newrect;
AdjustWindowRect(&newrect, WS_BORDER, true);
cout << "Hello, world, from Visual C++!" << endl;
}
此代码无法编译,有超过 500 个错误。最常见的是HWND is undefined。我很困惑,因为 winuser 是标准标题。请问怎么修?主要目标是编写将给我 hwnd 窗口大小的代码,这是一些如何使用 AdjustWindowRect 函数接近目标的第一个示例。
解决方案
永远不要<winuser.h>
直接包含,<windows.h>
而是包含,可能WIN32_LEAN_AND_MEAN
先定义,以减少该标题带来的所有内容。
推荐阅读
- vb.net - 根据文本框输入在组合框中选择值
- python - onchange 方法不适用于新记录
- hybris - hybris:无法创建 SourcingResults。将订单状态更改为 SUSPENDED
- go - 使用 DNSutil 从域中提取名称服务器 | dns.RR 类型没有字段或方法 Hdr
- linux - \n 不能在 sed 的 MacOS shell 上工作
- docker - 容器重启策略不适用于 Docker Compose(适用于 Docker CLI)
- react-admin - 如何使用自动建议作为 TextInput?
- python-3.x - NoSuchElementException:消息:没有这样的元素:尝试在 iframe 中查找元素时无法找到元素
- maximo - Maximo Anywhere - 离线工作订单规范
- python - 如何在 Tensorflow 中使用 3d 卷积?