如何在多显示器系统上检测最大化事件 [英] How to Detect Maximize event on multi-monitor system

查看:29
本文介绍了如何在多显示器系统上检测最大化事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 上,当系统有多个监视器时,C/C++ 如何检测 WM_WINDOWPOSCHANGING 消息上的最大化事件"?也就是说,当窗口在任何显示器上最大化时?

On windows, C/C++ how do I detect the "maximize event" on WM_WINDOWPOSCHANGING message when the system has multiple monitors? That is, when the window is maximized on any display?

(也欢迎其他操作系统的代码!)

(Code for other operating systems is also welcome!)

推荐答案

当窗口最大化时,尤其是作为交互式用户操作的结果,它接收 WM_SYSCOMMAND SC_MAXIMIZE 消息.

When window is to get maximized, esp. as a result of interactive user action, it receives WM_SYSCOMMAND SC_MAXIMIZE message.

最大化过程通常涉及WM_GETMINMAXINFO 消息,处理哪些...

Maximization process typically involves WM_GETMINMAXINFO message, handling which...

应用程序可以使用此消息来覆盖窗口的默认最大化大小和位置,或其默认的最小或最大跟踪大小.

An application can use this message to override the window's default maximized size and position, or its default minimum or maximum tracking size.

检测当前监视器工作区坐标可能最简单的是MonitorFromRect API:

To detect current monitor work area coordinates perhaps the easiest is MonitorFromRect API:

HMONITOR hMonitor = MonitorFromRect(&rcCenter, MONITOR_DEFAULTTONEAREST);
if(hMonitor)
{
    MONITORINFO MonitorInfo = { sizeof MonitorInfo };
    GetMonitorInfo(hMonitor, &MonitorInfo);
    // NOTE: MonitorInfo.rcWork is what you look for

这篇关于如何在多显示器系统上检测最大化事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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