为什么 MonitorFromWindow 缺失/未声明?(C++/维纳皮)
Why is MonitorFromWindow missing/not declared? (C++/WINAPI)
我正在试用Windows API,遇到了很多问题。最近的是这样的:我包含了Windows.h,暂时包括了Winuser.h,但MonitorFromWindow(以及相关的字段,如MONITOR_DEFAULTTONEAREST)丢失了。具体说来
...'MONITOR_DEFAULTTONEAREST' was not declared in this scope
和
...'MonitorFromWindow' was not declared in this scope.
其他方法显示得很好,如LoadImage和CreateWindow。我缺少一些包含内容吗?我不认为这是我调用方法的方式,甚至不是我包含头文件的方式,但如果你问,我仍然可以发布我的代码。没有多少。
编辑:当我检查范围中定义的内容时,最近的方法是ModifyWorldTransform(...)和MonikerCommonPrefixWith(...);最近的字段都以MONITOR_INFO开头,除了MONITOR_ENUMPROC。无MONITOR_DEFAULTTONEAREST/空/等。
编辑 2:
#define UNICODE
#define _WIN32_WINNT 0x0500
#include <iostream>
#include <process.h>
#include <windows.h>
#include <winuser.h>
。
HMONITOR monitor = NULL;
HWND CreateFullScreenWindow(HWND hwnd){
if(monitor==NULL){
monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
}
return hwnd;
}
#define UNICODE
#define _WIN32_WINNT 0x0500 // Windows 2000
#include <windows.h>
auto main() -> int
{
(void) MonitorFromWindow;
}
只有当工具链支持Windows 2000或更早版本时,这才是一个问题,就像MinGW g++编译器所做的那样。
MinGW g++ 4.7.2 中的相关标题部分<winuser.h>
:
#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
WINUSERAPI HMONITOR WINAPI MonitorFromPoint(POINT,DWORD);
WINUSERAPI HMONITOR WINAPI MonitorFromRect(LPCRECT,DWORD);
WINUSERAPI HMONITOR WINAPI MonitorFromWindow(HWND,DWORD);
#endif
文档说
Minimum supported client
Windows 2000 Professional [desktop apps only]
我怀疑您需要将WINVER
设置为 0x500
或更高。
相关文章:
- 没有找到相关文章