Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

.net - Supporting DPI and Default Font Changes

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:

image

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...