简体   繁体   English

应用程序在比例为150%的监视器上正确显示,但不能在比例为100%的监视器上正确显示

[英]Application displays correctly on a 150% scaled monitor but not on a 100% one

I am currently developing an application in c# with .NET Framework 4.7 I have a problem with DPI scaling. 我目前正在使用.NET Framework 4.7在c#中开发应用程序,但DPI​​缩放存在问题。 On my computer I have two monitors, one with 150% scaling and another one with 100%. 在我的计算机上,我有两台显示器,一台具有150%的缩放比例,另一台具有100%的缩放比例。 I added this code in my app manifest file: 我在应用清单文件中添加了以下代码:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
  <asmv3:application  xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

And it works perfectly fine. 而且效果很好。

正确显示后的外观

i take the exe file and all its dependecies, take it to another computer who as only one screen with 100% scaling and the application doesn't look as it should do. 我将exe文件及其所有依赖项带到另一台计算机上,该计算机仅是一个具有100%缩放比例的屏幕,并且该应用程序看上去并不像它应该做的那样。

未正确显示时的外观

I hope you guys have a solution for me I am struggling since two days with this problem... 我希望你们对我有解决方案,因为两天以来我一直在为这个问题而苦苦挣扎...

Well, like every time I post my problem I figure out the solution a few moments later. 好吧,就像我每次发布问题时一样,稍后我会找出解决方案。

I removed the manifest file from the application and changed the AutoScaleMode propertie to Dpi instead of Font for every form in my application. 我从应用程序中删除了清单文件,并将应用程序中每种表单的AutoScaleMode属性更改为Dpi而不是Font

And now it works like a charm. 现在,它就像一种魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM