Reputation: 1899
I am trying to set the maximum size a windows form can be set to, which may be different depending on what data needs to be displayed.
Is there a way to get the size of the borders around your windows form without having to calculate it yourself?
Currently, I have used the difference of the Size
and ClientSize
properties, like:
windowDressingWidth = this.Size.Width - this.ClientSize.Width;
windowDressingHeigth = this.Size.Height - this.ClientSize.Height;
Which works, but seems a bit backwards. Is there some sort of SystemInformation
or similar variable that stores this (like SystemInformation.HorizontalScrollBarHeight
does for the scroll bar height).
The closest I've found is SystemInformation.FrameBorderSize, which is 8 on my system, and that is half of my windowDressingWidth (16), so that might be for each side.
In the case of this program, it has no menu, but (on my system) has the aero borders all around, and the thicker one on top for the title and the Maximize, Minimize, and close controls.
Upvotes: 0
Views: 199
Reputation: 941455
The only other one you could need is SystemInformation.CaptionHeight
I should note that this is a bad idea. Always set the ClientSize property instead, that automatically ensures that the window is large enough to provide the client area you need. Also the way the designer works, when you set the form's Size property in the Properties window then the designer actually records the ClientSize value in the InitializeComponent() method. Which ensures your form still works on another machine where the user changed the preferences. Like the caption font and button sizes. Or a machine that has Aero turned off.
Upvotes: 2