Jump to content
  • Advertisement
Sign in to follow this  
Jacob Jingle

(C++, windows 7) Get/Set windows width, height and position?

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

How do I get/set a windows width, height and position under win7? Are WM_CREATE and WM_DESTROY the best times to save and load the data? Thx ahead of time.

Share this post


Link to post
Share on other sites
Advertisement
BAM!*

Quote:

Are WM_CREATE and WM_DESTROY the best times to save and load the data?


Sure.

*BAM! © 2010 "get window size win32", a subdivision of Google Inc. All rights reserved. The information contained in this website is for general information purposes only. The information is provided by Google and while we endeavor to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website. Through this website you are able to link to other websites which are not under the control of Google. We have no control over the nature, content and availability of those sites. The inclusion of any links does not necessarily imply a recommendation or endorse the views expressed within them. Every effort is made to keep the website up and running smoothly. However, Google takes no responsibility for, and will not be liable for, the website being temporarily unavailable due to technical issues beyond our control.

Share this post


Link to post
Share on other sites
Note that the dimensions GetWindowRect returns are in window coordinates, including the non-client areas.
If you want to determine the client area dimensions, use GetClientRect.
If you want to resize a window such that the client area is a particular size:

  • Fetch the rects wndRect = GetWindowRect and clientRect = GetClientRect

  • The new window width is newClientWidth + wndRect.right - wndRect.left - clientRect.right

  • Similarly, the new window height is newClientHeight + wndRect.bottom - wndRect.top - clientRect.bottom

Share this post


Link to post
Share on other sites
Quote:
Original post by Endurion
You can use the function GetWindowRect to get location/size or Get/SetWindowPlacement for the full states.

To move/size a window use SetWindowPos.

Thx.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zao
Note that the dimensions GetWindowRect returns are in window coordinates, including the non-client areas.
If you want to determine the client area dimensions, use GetClientRect.
If you want to resize a window such that the client area is a particular size:

  • Fetch the rects wndRect = GetWindowRect and clientRect = GetClientRect

  • The new window width is newClientWidth + wndRect.right - wndRect.left - clientRect.right

  • Similarly, the new window height is newClientHeight + wndRect.bottom - wndRect.top - clientRect.bottom


Or of course you can use the handy AdjustWindowRectEx function.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!