Sign in to follow this  
Roof Top Pew Wee

[.net] Getting client area of a window.

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
yup, for me always returns 0,0,400,400. The drawable area is 400 wide and tall, but that neither tells me the border width on each side nor the absolute screen postion of the drawable area.

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

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