有没有办法确定显示器的物理尺寸? [英] Is there a way to determine the physical size of the monitor?

查看:27
本文介绍了有没有办法确定显示器的物理尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以英寸为单位,例如21' 显示器.该应用是标准的 WinForms 应用.

In inches, e.g. 21' monitor. The app is a standard WinForms app.

看来确实没有一种可靠的方法来完成我所需要的.

It appears there really isn't a reliable way to accomplish what I need.

推荐答案

我正在考虑两种可能在特殊条件下工作的方法:

I am thinking about two ways that might work under special conditions:

  • 尝试获取监视器硬件的名称.在我的双显示器系统上,我使用一台 SyncMaster 205BW 和一台 SyncMaster 173T.这些是 20 英寸和 17 英寸显示器.你明白我的意思吗?但是,一个问题是我不确定您是否可以通过编程方式获取这些字符串.Windows 似乎只获取 SyncMaster:screenres.png.

您可以使用 GetDeviceCaps(GetDC(GetDesktopWindow), VERTSIZE) 获取物理屏幕的高度,以毫米为单位".与 HORZSIZE 和宽度"类似.但我相信,这只有在您校准了显示器后才有效.至少在我的系统上,这些值远大于实际的高度和宽度...

You can use GetDeviceCaps(GetDC(GetDesktopWindow), VERTSIZE) to obtain "Height, in millimeters, of the physical screen." and similarly with HORZSIZE and the "width". But this will only work if you have calibrated your display, I believe. At least on my system, the values are much larger than the actual height and width...

我不知道您的上下文,但如果您的应用确实需要最终用户输出设备的物理尺寸,为什么不询问他?您可以在设置期间轻松询问显示器的大小(例如使用出色的 Inno Setup),并将该值存储在注册表中.然后编写一个简单地从注册表读取值的过程 GetPhysicalMonitorSize 是微不足道的.

I have no idea about your context, but if your app really does need the physical size of the end-user's output device, why not ask him? You could easily ask for the monitor's size during setup (e.g. using the excellent Inno Setup), and store the value in the registry. Then it is trivial to write a procedure GetPhysicalMonitorSize that simply reads the value from the registry.

这篇关于有没有办法确定显示器的物理尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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