根据屏幕分辨率自动调整窗口大小 [英] Auto adjust windows form size according to screen resolution

查看:636
本文介绍了根据屏幕分辨率自动调整窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends,



我正在使用visual studio 2008开发桌面应用程序。我有一些没有边框的表单。我在表单中添加了一些图片框,按钮和标签。我想根据不同的屏幕分辨率调整表单大小(也是相应的控件大小)(屏幕比例3:2,4:3,5:3,5:4,8:5,16:9和17:9)。怎么做请帮我。



提前谢谢你

Hello Friends,

I am developing a desktop application using visual studio 2008. I have some forms without border. i add some picturebox, button and label in my form. I want to adjust form size (also corresponding control size) according to different screen resolution (Screen ratio 3:2, 4:3, 5:3, 5:4, 8:5, 16:9 and 17:9) . how it can be done. Please help me.

Thank you in advance

推荐答案

在实践中它是不可取的 - 它通常不会如果你这样做,你会提供一个很好的界面,除非你自己投入大量的工作。例如,很容易让按钮调整大小以适应表单,但按钮标题使用的字体大小不会随按钮重新缩放,因此您最终会得到一个大按钮,中间有小文本,或者一个小按钮,显示单个字符。



如果你需要这样做,那么你需要从标准的WinForms转移到WPF - 它可以很好地处理它!
In practice it isn't advisable - it doesn't normally present a good interface if you do, unless you put a lot of work into it yourself. For example, it is easy to get buttons to resize to fit the form, but the font size used for the button caption doesn't rescale with the button, so you end up with a large button, with tiny text in the middle, or a small button, with a single character displaying.

If you need to do this, then you need to move from standard WinForms to WPF - it can handle it very nicely!


使用Dock和Anchor属性。以下是一篇好文章。请注意,这些将在最大化/最小化时处理更改。这有点不同,如果屏幕分辨率发生变化,但它会有相同的想法。



http://www.techrepublic.com/article/manage -winform-controls-using-the-anchor-and-dock-properties /#.
Use Dock and Anchor properties. Below is a good article. Note that these will handle changes when maximizing/minimizing. That is a little different that if the screen resolution changes, but it will be along the same idea.

http://www.techrepublic.com/article/manage-winform-controls-using-the-anchor-and-dock-properties/#.


这里有一个古老的类似的好问题答案



如何调整win form应用程序的屏幕根据系统分辨率 [ ^ ]
Here an old similar nice question with answers

How to adjust screen of win form application According to System Resolution[^]


这篇关于根据屏幕分辨率自动调整窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆