正确的方式来处理自动缩放

正确的方式来处理自动缩放

本文介绍了正确的方式来处理自动缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与一个WinForms应用程序的另一个开发者,并且我们有一个很大的问题,涉及到自动缩放的外观。

我的系统(索尼VAIO),默认为125%,在此菜单中:

这是我可以告诉,125%设置DPI为120,和默认字体大小(菜单等)到11磅。在另一个开发者的系统,其缺省值为100%,这是96 dpi的,和9pt的字体。我不知道,但我想只有DPI是什么原因造成我们的悲痛。

这个问题表现出来的文字是错误的大小,并要么掩盖其他控件,或者被太多隔开(取决于谁拥有它的设计师最后一个打开的)。据我所知,所有的一个ContainerControl ,则设置为 AutoScaleMode.Inherit ,和顶级的形式是 AutoScaleMode.Dpi 。难道这是大多数其他人使用?

解决方案

我有同样的问题与我的应用程序的一个

。答案是将其移动到WPF。我带着我的时候仍然使用的WinForms的解决方案是有2个可执行文件。一个开发96DPI下和120DPI下其他。这是双重努力,但我曾尝试没有成功的任何布局配置。如果我的对照组在96DPI看起来很不错,切换至120DPI的时候,他们是窗外的应用。反之亦然。

WPF是唯一的解决这个恼人的问题。

I'm working with another developer on a WinForms application, and we are having a big problem with the appearance related to auto scaling.

My system (a Sony VAIO) defaults to 125% on this menu:

From what I can tell, 125% sets the DPI to 120, and default font size (menus, etc.) to 11pt. On the other developer's system, his defaults to 100%, which is 96 dpi, and 9pt font. I'm not sure, but I think only the DPI is what is causing us grief.

The problem manifests itself with text being the wrong size, and either covering up other controls, or being way too spaced out (depending on who had it open in designer last). As far as I can tell, all ContainerControls are set to AutoScaleMode.Inherit, and the top-level form is AutoScaleMode.Dpi. Is this what most other people use?

解决方案

I had the same problem with one of my applications. The answer was to move it to WPF. The solution that I came with when I still used WinForms was to have 2 executable files. One developed under 96DPI and the other under 120DPI. It was double effort, but I have tried any layout configurations without success. If my controls were looking fine on 96DPI, when switching to 120DPI, they were out of the window's application. And viceversa.

WPF is the only solution to this annoying problem.

这篇关于正确的方式来处理自动缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 02:59