Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

psykr

Win32 client and non-client coordinates

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

I wrote a settings saver class that saves game settings to an .ini file, and then loads them on startup. Whenever there''s a WM_MOVE message, I send the new window coordinates to the settings class. However, when I load these coordinates later, and set the window position with them, the window shifts slightly. It turns out that the WM_MOVE message sends the coordinates as those of the client area, while CreateWindowEx() uses them as the coordinates of the whole window, including the non-client area. How can I determine the offset from the non-client area to the client area??

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Why not just call GetWindowPos?

Share this post


Link to post
Share on other sites
Adjustwindowrect will do what you need. here: (quoted from my special win32 reference thingy)
The AdjustWindowRect function calculates the required size of the window rectangle based on the desired client-rectangle size. The window rectangle can then be passed to the CreateWindowEx function to create a window whose client area is the desired size.

BOOL AdjustWindowRect(

LPRECT lpRect, // pointer to client-rectangle structure
DWORD dwStyle, // window styles
BOOL bMenu // menu-present flag
);


Parameters

lpRect

Pointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.

dwStyle

Specifies the window styles of the window whose required size is to be calculated.

bMenu

Specifies whether the window has a menu.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

A client rectangle is the smallest rectangle that completely encloses a client area. A window rectangle is the smallest rectangle that completely encloses a window.
The AdjustWindowRect function does not add extra space when a menu bar wraps to two or more rows.

See Also

AdjustWindowRectEx, CreateWindowEx, RECT



-If you see this image I may or may not be online
My website

[edited by - brassfish89 on August 18, 2003 10:01:55 PM]

Share this post


Link to post
Share on other sites
Thanks brassfish, but that''s not exactly what I was looking for Let me see if I can clarify.. (or repeat myself ) given the coordinates upper-left corner of the client area, how can I determine the coordinates of the upper-left corner of the entire window, including the non-client area?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok, again I ask, why not GetWindowPos?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I mean, GetWindowRect, yeah thats what I meant .

Share this post


Link to post
Share on other sites
That seems a little redundant.. calling GetWindowRect whenever WM_MOVE happens.. but I guess it works.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by psykr
That seems a little redundant.. calling GetWindowRect whenever WM_MOVE happens.. but I guess it works.

that''s why it''s better to call GetWindowRect once, right before the window is destroyed, for instance (WM_CLOSE processing?) or maybe on receipt of WM_EXITSIZEMOVE since WM_MOVE is received many times as the window is moved around.

also take a look at WM_WINDOWPOSCHANGED, which receives a WINDOWPOS struct which contains the window''s x and y screen coords.

Share this post


Link to post
Share on other sites

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