Sign in to follow this  
Skiller

Window position and WM_MOVE

Recommended Posts

Skiller    122
I'm trying to get my game to remember the position of it's window when switching between full screen and windowed. The way I'm currently doing things is that whenever the window is moved in windowed mode I store the X and Y coordinates from the WM_MOVE message, then when I switch to full screen and back I pass those stored coordinates to CreateWindowEx when it creates the windowed mode window. This mostly works but it seems the coordinates I get from the WM_MOVE message are for the top-left of the client area and the coordinates for CreateWindowEx are expected to be for the top-left of the window including the borders. The result is that when I switch from full screen to windowed the window is positioned down and to the right of where I want it equal to the size of the window border :(. Anyone know of a way to fix this?

Share this post


Link to post
Share on other sites
szecs    2990
Or simply you could call GetWindowRect right before switching to fullscreen to get the position data.

But shouldn't switching back to windowed mode restore the window position by default? Just like when maximizing/restoring the window. I may be wrong...

Share this post


Link to post
Share on other sites
Skiller    122
Quote:
Original post by szecs
But shouldn't switching back to windowed mode restore the window position by default? Just like when maximizing/restoring the window. I may be wrong...


I'm creating and destroying the windows to switch from windowed to full screen or back to windowed so unfortunately no. If it can be done without creating and destroying the windows though I'd love to know how.

At any rate your suggestion about the window rect led me to look at the data and luckily for me the top and left values of it can just be added to the position to get what I want, thanks :).

Share this post


Link to post
Share on other sites
Endurion    5407
It can be done without destroying. You can move the window with SetWindowPos.

Also, at least with DX9 you have to modify the window styles on the fly. Use SetWindowLong along with SetWindowPos and SWP_FRAMECHANGED.

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