Sign in to follow this  
Jacob Jingle

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

Recommended Posts

fastcall22    10846
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
Zao    985
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
Jacob Jingle    226
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
MJP    19791
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

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