监视器更改时,DeviceDPI不会更改返回值 [英] DeviceDPI doesn't change returned value when monitor changed

查看:69
本文介绍了监视器更改时,DeviceDPI不会更改返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是在错误的论坛;但是我找不到一个讨论这种事情的人(!)

This may be in the wrong forum; but I can't find one that discusses this kind of thing(!)

我有一个应用程序我正试图让DPI意识到。我正在使用.NET 4.7。我按照https://docs.microsoft.com/en-gb/dotnet/framework/winforms/high-dpi-support-in-windows-forms中的建议添加了配置和调用,包括

I've an application I'm trying to make DPI aware. I'm using .NET 4.7. I've added the configuration and calls as recommended in https://docs.microsoft.com/en-gb/dotnet/framework/winforms/high-dpi-support-in-windows-forms, including the

< add
key = " DpiAwareness"
value = " PerMonitorV2"
/>
 

<add key="DpiAwareness" value="PerMonitorV2" /> 

当我运行应用程序时,会调用DeviceDPI并调整各种元素大小取决于设备的DPI。但是,如果我将应用程序拖动到具有不同DPI的另一个监视器,我希望DeviceDPI()
的返回值更改 - 我为resizeend事件添加了一个处理程序表单,当表单被拖动到另一个监视器时触发,但随后对DeviceDPI()的调用返回"旧"监视器的dpi。我还为DpiChanged事件添加了一个处理程序
- 这不是监视器更改时调用。

When I run the application, a call is made to DeviceDPI and various elements are adjusted in size depending on the DPI of the device. However, if I drag the application to another monitor with a different DPI, I would expect the return value of DeviceDPI() to change - I added a handler for resizeend events for the form, which fires when the form is dragged to another monitor, but the subsequent call to DeviceDPI() returns the dpi of the "old" monitor. I also added a handler for the DpiChanged event - that doesn't get called when the monitor changes.

有关如何获取运行应用程序的监视器DPI的任何建议吗?

Any suggestions about how to get the DPI of the monitor the application is running on?

-Andrew

AndrewFromEssex

AndrewFromEssex

推荐答案

<你好安德鲁,

感谢你的帖子。

这个论坛用于讨论WCF开发问题,你的问题是与winform更相关,我将把这个帖子移到更相关的论坛。

This forum is used to discuss about WCF developing issue, your issue is more related with winform, I will move this thread to the more related forum.

参考:
https://social.msdn.microsoft.com/Forums/windows/en-US/home?forum=winforms

感谢您的理解。

最好的问候,

Edward


这篇关于监视器更改时,DeviceDPI不会更改返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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