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.
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
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!