Question

I have already written at https://stackoverflow.com/questions/13396293/getting-correct-winforms-forms-border-width-when-changing-formborderstyle-from that .NET WindowsForms package has some problems with calculating the border size. Now I need to know how to retrieve the height of the title bar part of a form with the FormBorderSize property set to 'SizableToolWindow'.

Was it helpful?

Solution 2

Sorry, it seems overlooked this thing in the managed tools before asking:

SystemInformation.ToolWindowCaptionHeight

OTHER TIPS

I calculate a title bar heigh for any form, using the following, valid for normal forms or SizableToolWindow:

Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle);
int titleHeight = screenRectangle.Top - this.Top;

Hope it helps.

This is my way of finding the height of the titlebar in a winform. This also works when the form is hidden. Code is VB.NET.

Dim TitlebarHeight as Integer = (Me.Height - Me.ClientSize.Height)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top