GetSystemMetrics() 为 SM_CXSCREEN 返回错误的值 [英] GetSystemMetrics() returns wrong value for SM_CXSCREEN

查看:32
本文介绍了GetSystemMetrics() 为 SM_CXSCREEN 返回错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的问题.至少在 Vista 中,当桌面 DPI 设置未设置为 100% 时,getSystemMetrics(SM_CXSCREEN) 返回不正确的值.例如,我在 1366x768 屏幕中尝试了 150% 并且 getSystemMetrics() 返回 911 而不是 1366(和 1366/1.5 ~ 911)

I've run into an interesting problem. At least in Vista, getSystemMetrics(SM_CXSCREEN) returns an incorrect value when the desktop DPI settings aren't set at 100%. For example, I tried 150% in a 1366x768 screen and getSystemMetrics() returns 911 instead of 1366 (and 1366 / 1.5 ~ 911)

根据 MSDN,getSystemMetrics(SM_CXSCREEN) 返回像素,所以我认为这个值不会受到 DPI 设置的影响 - 但它是.那么有没有更安全的方法来找出真实的、未缩放的屏幕分辨率?

According to the MSDN, getSystemMetrics(SM_CXSCREEN) returns pixels, so I thought this value wouldn't be affected by the DPI settings - but it is. So is there a safer way to find out the true, unscaled screen resolution?

推荐答案

当你超过 125% 时,程序必须告诉操作系统它是 DPI 感知的才能获得真正的分辨率.最好使用清单来完成,如此 MSDN Library 中所述文章.

A program must tell the operating system that it is DPI-aware to get the true resolution when you go past 125%. That's best done with a manifest, as explained in this MSDN Library article.

这篇关于GetSystemMetrics() 为 SM_CXSCREEN 返回错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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