Sign in to follow this  

[.net] Getting client area of a window.

This topic is 4480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This seems like it'd be the easiest thing to do but I've looked through the docs and googled it and I can't figure out how to get my client area of a window. For example, I set my FormBorderstyle to System.Windows.Forms.FormBorderstyle.FixedDialog. My window (including border) has dimensions of x: 406, y: 432 but the actual drawable area is 400 by 400. I'm trying to figure out the border width. Sure, I could just take the difference of the widths (6) divide by 2 (3) and get the side (and probably bottom) borders, then subtract that from the height difference for the title bar at the top, but is this really the way that it's done? I can't imagine that there's no way to get the absolute position of the client area, or the border width/title bar height of a window. --Vic--

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Form1.ClientSize.Width (or .Height) should be what you want.

Just tested it. My window has a width of 616. ClientSize.Width returns 608. And I have a panel docked as client with the same size.

Share this post


Link to post
Share on other sites
AP: yeah, I realize that means you have 8 pixels of non-client width, meaning your borders are 4 wide. But I want to be sure that this is the best way to get the width and height. I know it's prob not the case, but I don't want to ever assume that the side borders are just as wide as the bottom borders of the window when I calculate the width of the title bar.

--Vic--

Share this post


Link to post
Share on other sites

This topic is 4480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this