Winforms位置和尺寸属性 [英] winforms position and dimension properties

查看:62
本文介绍了Winforms位置和尺寸属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清winforms的所有位置和尺寸属性,如果有一个全面的概述来解释它们之间的关系,这将非常有帮助.他们中的许多人似乎在功能上是等效的,但是我担心我可能会做出一些错误的假设.

I'm trying to untangle all the position and dimension properties of winforms, and it would be really helpful if there were a comprehensive overview explaining the relationships between them. Many of them appear to be functionally equivalent, but I'm concerned I may be making some false assumptions.

作为参考,我指的是诸如Screen.PrimaryScreen.Bounds与Form.DesktopBounds之类的属性; Form.ClientRectangle与Form.DisplayRectangle; Form.left与Form.Location.X; PointToScreen与Cursor.Position等.我还对多个监视器对位置属性的影响特别感兴趣.

For reference, I am referring to properties such as Screen.PrimaryScreen.Bounds vs Form.DesktopBounds; Form.ClientRectangle vs Form.DisplayRectangle; Form.left vs Form.Location.X; PointToScreen vs Cursor.Position, and so forth. I'm also particularly interested in the effect of multiple monitors on the position properties.

如果有人知道带有注释的图表,将其全部列出,那将非常棒.

If anyone knows of an annotated diagram laying this all out, that would be awesome.

推荐答案

作为部分答案,描述您在上面列出的那些属性:

As a partial answer, describing those properties you list above:

  • Screen.PrimaryScreen.Bounds为您提供主监视器的尺寸.在多显示器设置中,无论哪个屏幕设置为主屏幕.
  • Form.DesktopBounds 给出您就是整个桌面"的组合边界,这是一个跨越所有活动监视器的虚拟画布.
  • Form.ClientRectangle 提供表单客户区域的面积(矩形)(chrome内的空间)
  • Form.DisplayRectangleForm.ClientRectangle相似,但包括镶边(标题栏和窗体周围的边框)
  • Form.Location.XForm.Left实际上是同一件事(也适用于top和Y),使用左上角作为0,0原点,并向右下角增加xy
  • PointToScreen 返回屏幕"坐标-但似乎相对于桌面总面积; Cursor.Position 返回相似的值
  • Screen.PrimaryScreen.Bounds gives you the dimensions for the main monitor. On a multi-monitor setup that is whichever screen is set as primary.
  • Form.DesktopBounds gives you the combined boundary for the entire "desktop", which is a virtual canvas spanning all active monitors.
  • Form.ClientRectangle provides the area (rect) of the client area of the form (the space inside the chrome)
  • Form.DisplayRectangle is similar to Form.ClientRectangle but includes the chrome (title bar and border around form)
  • Form.Location.X and Form.Left are effectively the same thing (also applies to top and Y) using top-left as 0,0 origin and increasing x and y towards the bottom right
  • PointToScreen returns the "screen" coordinate - but seems to be relative to the total desktop area; Cursor.Position returns a similar value

如果您想了解有关客户端屏幕配置的更多信息,请查看 AllScreens 属性,可为您提供完整设置的详细信息.

If you're wanting to learn more about the screen configuration on the client then check out the Screen class on MSDN. Of some interest might also be the AllScreens property, which gives you details on the full setup.

修改:

好-一个(简单的)概述;-)我也可以偷懒!

Ok - a (simple) overview ;-) I can be lazy too!

这篇关于Winforms位置和尺寸属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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