DisplayInformation返回错误的每显示缩放因子 [英] DisplayInformation returns wrong per-display scaling factor

查看:105
本文介绍了DisplayInformation返回错误的每显示缩放因子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我使用  DisplayInformation来检索显示比例因子,请参阅下面的代码:

I use DisplayInformation to retrieve the display scaling factor, see the code below:

	auto dispInfo = Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
	int screenScaleFactor = (int)(dispInfo->ResolutionScale); //The display scaling factor

当Windows连接到单个监视器时,代码返回正确的缩放系数。 

The code returns correct scaling factor when Windows connect to a single monitor. 

但是,当将Windows输出设置为"扩展桌面"时,即外部监视器+内置显示器,并且每个都有自己的(不同的)缩放因子时,代码始终返回主显示器的缩放因子。结果,当在辅助显示器中启动我的UWP
应用程序时,它得到了错误的缩放因子。

However, when set Windows output to "extended desktop", i.e., External Monitor + Built-in Display, and each has it own (different) scaling factor, the code always return the primary display's scaling factor. As the result, when launch my UWP application in the secondary display, it got the wrong scaling factor.

上面的屏幕截图显示我将Windows输出到扩展桌面并结合外部显示器(主要),150%缩放和内置显示器(辅助),200%缩放。当我的UWP应用程序在辅助显示器(200%)中启动时,代码仍然是
返回主显示缩放(150%),这会导致问题。

Above screenshot shows that I output Windows to extended desktop combined with external display (primary) with 150% scaling and built-in display (secondary) with 200% scaling. When my UWP application launched in the secondary display (200%), the code still return the primary display scaling (150%), which causes problem.

我构建了我的UWP同时使用SDK 10.0.10586和10.0.14393的应用程序并得到了相同的错误结果。

I built my UWP app with both SDK 10.0.10586 and 10.0.14393 and got the same wrong result.

有没有办法获得正确的每显示缩放系数?感谢您的任何建议。

Is there way to get correct per-display scaling factor? Thanks for any suggestion.

推荐答案

Hello Toothy Bunny,

Hello Toothy Bunny,

我想你调用你的代码在CoreWindow激活之前。  为了获得正确的结果,请在CoreWindow激活后调用您的代码,例如在激活的事件 处理程序 

I think you invoke your code before the CoreWindow is activated.  For getting correct result invoke your code after CoreWindow is activated for example in Activated event  handler 

        Window.Current.Activated += Current_Activated;
        Window.Current.Activate();

        private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
        {
            var info = DisplayInformation.GetForCurrentView();
        }


这篇关于DisplayInformation返回错误的每显示缩放因子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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