为什么MonitorFromWindow缺少/未声明? (C ++ / WINAPI) [英] Why is MonitorFromWindow missing/not declared? (C++/WINAPI)

查看:1429
本文介绍了为什么MonitorFromWindow缺少/未声明? (C ++ / WINAPI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试Windows API,我遇到了很多问题。最近的是:我包括Windows.h和临时Winuser.h,但MonitorFromWindow(和相关字段,如MONITOR_DEFAULTTONEAREST)缺失。具体来说,

I'm trying out the Windows API, and I've run into a lot of problems. The most recent is this: I included Windows.h, and temporarily Winuser.h, yet the MonitorFromWindow (and the associated fields, like MONITOR_DEFAULTTONEAREST) are missing. Specifically,

...'MONITOR_DEFAULTTONEAREST' was not declared in this scope

...'MonitorFromWindow' was not declared in this scope.

其他方法显示得很好,比如LoadImage和CreateWindow。有没有一些包括我错过了?我不认为这是我调用的方法,甚至我的方式,我包括头文件,但如果你问,我仍然可以发布我的代码。

Other methods show up just fine, like LoadImage and CreateWindow. Is there some inclusion I'm missing? I don't think it's the way I've called the methods, or even the way I included the header files, but if you ask, I can still post my code. There's not much of it.

编辑:当我检查范围中定义的内容时,最近的方法是ModifyWorldTransform(...)和MonikerCommonPrefixWith(...) ;最近的字段都以MONITOR_INFO开头,MONITOR_ENUMPROC除外。 No MONITOR_DEFAULTTONEAREST / NULL / etc。

when I check what is defined in the scope, the nearest methods are ModifyWorldTransform(...) and MonikerCommonPrefixWith(...); the nearest fields all begin with MONITOR_INFO, except for MONITOR_ENUMPROC. No MONITOR_DEFAULTTONEAREST/NULL/etc.

编辑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 ++编译器。

This is only a problem if the toolchain supports Windows 2000 or earlier, as evidently the MinGW g++ compiler does.

MinGW g ++ 4.7.2的相关标题部分 ; winuser.h>

The relevant header section from the 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

这篇关于为什么MonitorFromWindow缺少/未声明? (C ++ / WINAPI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆