如何区分外部显示器和笔记本电脑的屏幕本身? [英] How to differentiate external monitor(s) from the notebook's screen itself?

查看:277
本文介绍了如何区分外部显示器和笔记本电脑的屏幕本身?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我解释一下我的情况。我编写一个程序,只有当用户看到屏幕时,才应该执行某些绘图/渲染操作。在笔记本电脑的情况下,这意味着 - 只有当盖子打开时。确定我对GUID_LIDSWITCH_STATE_CHANGE使用了PBT_POWERSETTINGCHANGE通知,这对于单个监视器系统非常有用。

Let me explain my situation. I write a program that should perform certain drawing/rendering actions only when a user sees the screen. In case of a notebook, this means -- only when the lid is open. To determine that I use the PBT_POWERSETTINGCHANGE notification for GUID_LIDSWITCH_STATE_CHANGE, which works great for a single monitor system.

当一个或多个外部连接的显示器连接到笔记本计算机时, 。在这种情况下,主笔记本屏幕可以保持不活动,而只有外部监视器被通电。所以在这种情况下,盖子会报告为关闭,这应该使我的程序继续渲染。

The issue happens when there's one or more externally attached monitors connected to a notebook. In that situation the main notebook screen may remain inactive, while only external monitor(s) are powered on. So in that case the lid would be reported as closed, which should make my program to continue rendering. The problem is how to detect this situation.

我想我可以使用 GetSystemMetrics(SM_CMONITORS)来计算监视器。但在这种情况下,我不知道显示器是来自,或者换句话说,它是一个笔记本的原生屏幕,或外部插入一个。

I was thinking that I can count monitors using GetSystemMetrics(SM_CMONITORS) but in this case I don't know where the monitor is "coming from", or in other words, is it a notebook's "native" screen, or an externally plugged in one.

所以我的问题是,我可以在插入系统的任何外部监视器和笔记本的本地屏幕之间进行区分。

So my question is, can I defferentiate between any external monitors plugged in to the system versus the "native" screen of a notebook?

推荐答案

您可以致电 GetMonitorInfo 并询问在MonitorInfo结构中返回的标志。查找MONITORINFOF_PRIMARY。

You can call GetMonitorInfo and interrogate the flag that's returned in the MonitorInfo structure. Look for MONITORINFOF_PRIMARY.

这篇关于如何区分外部显示器和笔记本电脑的屏幕本身?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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