Jump to content
  • Advertisement
Sign in to follow this  
Roof Top Pew Wee

[.net] Getting client area of a window.

This topic is 4819 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!