[英]I included <winuser.h>, but compiler throws "was not declared" at MonitorFromWindow
There is already a post about it, but it didn't solve the error.已经有一篇关于它的帖子,但它没有解决错误。 I tried commenting out the if on winuser.h, but it did no effect.我尝试在 winuser.h 上注释掉 if,但没有效果。
// Header
#include <windows.h>
#include <winuser.h>
// Cpp
monitorA = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY); // Errors
GetMonitorInfo(monitorA, &monitorAInfo); // No error
error: 'MonitorFromWindow' was not declared in this scope错误:“MonitorFromWindow”未在此范围内声明
error: 'MONITOR_DEFAULTTOPRIMARY' was not declared in this scope错误:“MONITOR_DEFAULTTOPRIMARY”未在此范围内声明
Also, I am using Code::blocks with gcc compiler.另外,我在 gcc 编译器中使用 Code::blocks。
Assuming your copy of <winuser.h>
actually supports MonitorFromWindow()
, then make sure that you have WINVER
set to 0x0500
or higher to enable MonitorFromWindow()
.假设您的<winuser.h>
副本实际上支持<winuser.h>
MonitorFromWindow()
,然后确保您将WINVER
设置为0x0500
或更高以启用0x0500
MonitorFromWindow()
。 See the following for more details:有关更多详细信息,请参阅以下内容:
Using the Windows Headers: Setting WINVER or _WIN32_WINNT 使用 Windows 头文件:设置 WINVER 或 _WIN32_WINNT
Update WINVER and _WIN32_WINNT 更新 WINVER 和 _WIN32_WINNT
What's the difference between WINVER, _WIN32_WINNT, _WIN32_WINDOWS, and _WIN32_IE? WINVER、_WIN32_WINNT、_WIN32_WINDOWS 和_WIN32_IE 有什么区别?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.