当用户为操作系统字体大小选择125%或150%时,如何强制Windows Forms C#应用程序忽略? [英] How do I force a Windows Forms C# application to ignore when a user choose 125% or 150% for the OS font size?

查看:123
本文介绍了当用户为操作系统字体大小选择125%或150%时,如何强制Windows Forms C#应用程序忽略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种快速的方法来强制C#Windows Forms应用程序在用户在操作系统设置中选择更大或更小的百分比时不缩放字体。

I need a quick way of forcing my C# Windows Forms application to not scale fonts when a user choose a larger or smaller percentage in the OS settings.

这是

推荐答案

这是对我有用的东西...

Here is what worked for me...

        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
        this.Font = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));

以上两行是从我的BaseForm.Designer.cs文件中复制的,但是基本上我发现有两行很简单获得不缩放字体的步骤:

The above two lines are copied from my BaseForm.Designer.cs file, but basically I found two easy steps to get "no font scaling":


  1. 将AutoScaleMode设置为None。

  1. Set AutoScaleMode to None.

使用像素作为所有字体的单位类型,而不是默认的磅值。

Use "Pixel" as the Unit Type for all Fonts, instead of the default Point value.

就您是否应该让Windows缩放字体而定,这取决于您。我一个人不喜欢设计,所以如果我觉得我的应用程序需要扩展,我会自己做,并使用自己的选项和设计。

As far as if you should let Windows scale your fonts or not, that's up to you. I for one don't like the design, so if I feel my application needs to be scaled, I'll do it myself, with my own options and design.

在与实际最终用户交谈的多年中,我还发现他们中的大多数人对DPI设置一无所知,如果他们有默认设置以外的其他内容,那不是因为他们想要这样。 。并且他们只是从未注意到,因为他们使用的只是Web浏览器,也许还有Excel和Microsoft Word(使用他们设置的任何字体)。

Over the years of speaking with actual end-users, I've also found that most of them have no idea about DPI settings, and if they have anything other than the default set, it wasn't because they wanted it that way... and they just never noticed because all they use is the web browser and maybe Excel and Microsoft Word (which use whatever font they set it to).

如果我的应用程序有尊重系统字体设置,他们不会希望它==减少销量,因为它会像系统对话框一样拥有这种巨大的丑陋字体(而且他们不知道如何更改它,但是他们不喜欢)不在乎他们从未使用过的系统对话框)。

If my application had respected the system font settings, they wouldn't have liked it as much == less sales, because it would have had this huge ugly font like the system dialogs do (and they don't know how to change it, but they don't care about system dialogs they never use).

这篇关于当用户为操作系统字体大小选择125%或150%时,如何强制Windows Forms C#应用程序忽略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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