开发者

Winform application layout - dealing with different DPI practices

We have a winform MDI application, there's quite a lot of forms/dialogs. Some are laid out with absolute location and sizes, some are laid out using table/flow panels.

Overall appearance looked good under different screen resolutions. Until someone tested it on a machine where t开发者_运维问答he DPI was set to 120. While mostly things looked good, some controls here and there were way out of whack, overlapping other controls, pieces that had anchor = Right/Top didn't stick to the right anymore etc.

What are the practices developing winform applications that "works" under different DPIs ?

Are there any shortcuts helping developers test the app under different DPIs ?


The 'complete' answer is in this post: How to write WinForms code that auto-scales to system font and dpi settings?

For your case, do not anchor to the right, add a panel Docked right and move your control inside this new panel.

But read everything in the link above


In the event someone else finds this as yet unanswered question.

I encountered this today, and after searching, the best I've found is switching AutoScaleMode on all controls to Inherit (Find and Replace for designer files), and then after the generated InitializeComponent (probably just after ResumeLayout), Set AutoScaleMode to Font (or None... or Inherit). The common statement of set AutoScaleMode to DPI on everything didn't work, and actually failed more spectacularly then anything else.

From what I've found, it sounds like WPF fixes most/all of this by embracing it as part of the framework. Doesn't help for old winforms though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜