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

Était-ce utile?

La solution 2

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

SystemInformation.ToolWindowCaptionHeight

Autres conseils

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)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top