如何使用Windows C#应用程序的系统字体设置

对于Windows应用程序(C#),是否可以调整整个应用程序(包括所有表单)以使用系统字体设置大小而不是使用固定大小?

这适用于视力受损的用户,他们在自己的机器上设置了更大的字体。 应用程序是否可以根据用户的具体情况调整字体。

如果希望应用程序按系统字体缩放,则应将所有表单的AutoScaleMode属性设置为值AutoScaleMode.Font如果希望通过Windows DPI设置缩放,则应将AutoScaleMode设置为AutoScaleMode

在这里您可以找到更多信息 – http://msdn.microsoft.com/en-us/library/ms229605.aspx

 // Get dpi width float x = this.CreateGraphics().DpiX; // if screen is width if (x == 120) // Get big image from Resources this.BackgroundImage = Properties.Resources.BigImage; else if (x==96) { // Get small image from Resources this.BackgroundImage = Properties.Resources.loading49; this.BackColor = ColorTranslator.FromHtml("#E6E6E6"); this.button2.Size = new Size(85, 30); this.button1.Size = new Size(75, 24); this.textBox1.Size = new Size(150, 40); }