Jump to content
  • Advertisement
Sign in to follow this  
lordikon

height/width inside a window?

This topic is 3475 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

Using GetWindowRect() seems to be giving me the size of the the window including the title bar and window borders. Is there a way to get the height/width of the inside of the window?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by lordikon
Using GetWindowRect() seems to be giving me the size of the the window including the title bar and window borders.

Is there a way to get the height/width of the inside of the window?
GetClientRect. If you're doing this at window creation, you should use AdjustWindowRect to create a window with the specified client area (Since CreateWindowEx takes the window size, not the client size).

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by lordikon
Using GetWindowRect() seems to be giving me the size of the the window including the title bar and window borders.

Is there a way to get the height/width of the inside of the window?
GetClientRect. If you're doing this at window creation, you should use AdjustWindowRect to create a window with the specified client area (Since CreateWindowEx takes the window size, not the client size).


NO! *swats Evil Steve with a newspaper* AdjustWindowRect() isn't accurate.

RECT rcWnd;
rcWnd.right = (GetSystemMetrics(SM_CXFRAME) * 2) + nWidth;
rcWnd.bottom = (GetSystemMetrics(SM_CYFRAME) * 2) + GetSystemMetrics(SM_CYCAPTION) + nHeight;
rcWnd.left = (GetSystemMetrics(SM_CXSCREEN) - rcWnd.right) / 2;
rcWnd.top = (GetSystemMetrics(SM_CYSCREEN) - rcWnd.bottom) / 2;



The above code accurately calculates the window size and centers it.

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!