Windows Forms resolution problem

后端 未结 3 1359
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 14:12

I have developed a 1024 *780 resolution screen in Windows Forms, but some say that it does not fit properly at higher resolutions. Is there any way to handle this?

3条回答
  •  再見小時候
    2021-01-13 14:50

    This is the sort of thing that makes you say "there's got to be a better way."

    My solution for this one time was to declare a global ScalingFactor variable that was tied to the current screen resolution. Then, the sizes of every visual element were multiplied by that factor.

    So, if I designed my form for resolution A, and resolution B is 1.2x larger, the width of window A will be with * 1.2, the fonts will be fontSize * 1.2, the textbox dimensions will be dimensions * 1.2.

    Not fun.

    There may be 3rd party tools that you can buy and will perform this scaling.

    One other thing to check before you run down any of these roads is whether it is actually the screen resolution or the dpi settings that are causing it to look bad. Usually a higher resolution will only make it look smaller, but an atypical dpi, such as when the user selects "large fonts" will wreak havoc.

提交回复
热议问题