How to get the size of a Winforms Form titlebar height?
There is an additional wrinkle in case your form is a view in an MDI application. In that case RectangleToScreen(this.ClientRectangle) returns coordinates relative not to Form itself (as one might expect) but with respect to MainForm which hosts MDIClient control hosting the Form.
You may to account for that by
Point pnt = new Point(0, 0);
Point corner = this.PointToScreen(pnt); // upper left in MainFrame coordinates
Point origin = this.Parent.PointToScreen(pnt); // MDIClient upperleft in MainFrame coordinates
int titleBarHeight = corner.Y - origin.Y - this.Location.Y;
You can determine titlebar height for both tool-windows and normal forms by using:
Rectangle screenRectangle = this.RectangleToScreen(this.ClientRectangle);
int titleHeight = screenRectangle.Top - this.Top;
Where 'this' is your form.
ClientRectangle returns the bounds of the client area of your form. RectangleToScreen converts this to screen coordinates which is the same coordinate system as the Form screen location.