winforms position and dimension properties

馋奶兔 提交于 2019-12-05 08:11:27

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

  • 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

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.

Edit:

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!