Supporting DPI and Default Font Changes

不羁岁月 提交于 2019-12-18 03:03:12

问题


So I'm trying to figure out how the Form's AutoScaleMode property can possibly help to support a system with a font or DPI that is different from my work development machine.

From the SDK:

AutoScaleMode Enumeration

public enum AutoScaleMode

None  
   Automatic scaling is disabled.    
Font   
   Controls scale relative to the dimensions of the 
   font the classes are using, which is typically the 
   system font.
Dpi    
   Controls scale relative to the display resolution. 
   Common resolutions are 96 and 120 DPI.

By default .NET 2.0 Forms use AutoScaleMode.Font.

So I designed a sample form on my Windows XP, Tahoma 8 pt, 96 DPI development machine. Then I tried it out on a

  • 14 pt Segoe UI 96 DPI machine
  • 14 pt Segoe UI 150 DPI machine

The results were not encouraging, as you can see in this screenshot:

The AutoScaleMode property was not designed to enable a .NET Form for support of different font or DPI settings. So what is the proper way to support different font and DPI settings?


回答1:


The correct way is to scale the controls, the form itself and the text within. This sounds very complicated, but the layout controls (TableLayoutPanel and FlowLayoutPanel), combined with the AutoSize property, make this considerably less difficult.



来源:https://stackoverflow.com/questions/196606/supporting-dpi-and-default-font-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!