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

查看:39
本文介绍了如何将 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 中的新功能是 dpiAwarenessdpiAware,因此我们需要更新此示例少量.现在,这很好,因为如果 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 支持(有关其他可能的选项,请参阅参考 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,因为我们不支持它):

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>

参考:微软在最新的 Windows 10 版本中的 DPI Awareness(也有关于如何让你的代码意识到 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天全站免登陆