如何在Windows应用程序清单中将dpiAware属性设置为“每个监视器",以便将其设置为“每个监视器".在Visual Studio中? [英] How can I set the dpiAware property in a Windows application manifest to "per monitor" in Visual Studio?

查看:988
本文介绍了如何在Windows应用程序清单中将dpiAware属性设置为“每个监视器",以便将其设置为“每个监视器".在Visual Studio中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够将应用程序清单中的dpiAware属性设置为每个监视器".属性中的可用选项仅用于启用或禁用DPI感知.这些设置都不适合我.如果不将清单嵌入到exe中,则可以得到我的应用程序想要的行为,然后手动编辑清单.我想自动生成并嵌入清单.有什么我想念的吗? (我正在使用Visual Studio 2013.)

I need to be able to set the dpiAware property in the manifest of my application to "per monitor". The available choices in the properties are just to enable or disable DPI awareness. Neither of these settings works for me. I can get the behavior I want for my application if I don't embed the manifest in the exe, then edit the manifest manually. I want to automatically generate and embed the manifest. Is there something I am missing? (I am using Visual Studio 2013.)

推荐答案

Windows 10中的新功能是 dpiAwareness dpiAware ,因此我们需要更新此示例少量.现在,这很好,因为如果 dpiAwareness 不存在,则设置将从 dpiAware 继承.

New in Windows 10 is dpiAwareness as well as dpiAware, so we need to update this example a bit. Now, it is fine because if dpiAwareness does not exist, then the settings will be inherited from dpiAware.

要完全启用DPI意识,请使用最新的Win10支持(有关其他可能的选项,请参阅Ref URL),其中包括" permonitor "和" permonitorv2 ",我将使用系统"而不是系统",因为您的问题会询问它.

To enable DPI awareness in full, with the latest Win10 support (see Ref URL for other possible options), which includes 'permonitor' and 'permonitorv2', which I will use instead of 'system' because your question asks it.

<asmv3:application>
  <asmv3:windowsSettings>
    <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- legacy -->
    <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to pm if pmv2 is not available -->
  </asmv3:windowsSettings>
</asmv3:application>

禁用,您需要执行相反的操作(由于我们不支持dpiAwareness,因此不需要dpiAwareness):

To disable, you'd do the opposite (no need for dpiAwareness since we don't support it):

<asmv3:application>
  <asmv3:windowsSettings>
    <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">unaware</dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>

如果您碰巧使用GDI对象来绘制一些自己的东西,那么甚至还有'gdiScaling'.

Then there is even 'gdiScaling' if you happen to use GDI objects to paint some of your own stuff.

<asmv3:application>
  <asmv3:windowsSettings>
    <gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
  </asmv3:windowsSettings>
</asmv3:application>

参考: Microsoft在最新的Windows 10版本上对DPI的了解(还有关于如何使您的代码了解DPI的教程,即使对于较大的项目来说这有点乏味)

Reference: Microsoft on DPI Awareness as of latest Windows 10 build (also has tutorials on how to make your code DPI aware, even if it is a little tedious for larger projects)

这篇关于如何在Windows应用程序清单中将dpiAware属性设置为“每个监视器",以便将其设置为“每个监视器".在Visual Studio中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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