• Advertisement
Sign in to follow this  

Prevent a window from moving - fixed

This topic is 3874 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 have an issue with the window containing the game itsself. In the message switch, I have the moving prevention as follows:
      case WM_MOVE:
      {
         return(FALSE);
         break;
      } break;



Yes, I know, the style looks disgusting. This switch statement still gets executed and returns false correctly but does not prevent the window from being moved. Any help here? Thanks in advance. PS: Game programming is my hobby, I am not yet using it commercially. [Edited by - Bob123456 on July 17, 2007 4:52:17 PM]

Share this post


Link to post
Share on other sites
Advertisement
it doesn't do anything because the message isn't "The user want to move the window" it's "The user did move the window". One way to solve it would be to reset the window's position when you receive WM_MOVE.

There's probably somebody more familiar with the Windows API that can point out some flag or another that disables that in the first place.

Share this post


Link to post
Share on other sites
I believe this problem cannot be solved by the message handler :)

If you wish to just stop user from moving the window. Try playing with the CreateWindowEx() function and its flags :)

That should do the trick ...

If you still can't figure it out ... let me know and I will post the code

Share this post


Link to post
Share on other sites
Thank you for replying. I now understand that WM_MOVE means that the user has already moved the window. I now have the following code:

      
case WM_MOVE:
{
SetWindowPos(hWindow0Reference, HWND_TOPMOST, 0, 0, window0Width, window0Height, NULL);
return(FALSE);
break;
} break;




This creates a flashy effect, because each time the user moves the window it immediately returns to its proper position. This is fine, but would preventing the window from moving at all be possible?

Quote:
Original post by The Lion King
I believe this problem cannot be solved by the message handler :)

If you wish to just stop user from moving the window. Try playing with the CreateWindowEx() function and its flags :)

That should do the trick ...

If you still can't figure it out ... let me know and I will post the code


Thank you for your post, but no MSDN page gives a flag that would solve this situation.

Share this post


Link to post
Share on other sites
You could try playing around with handling WM_GETMINMAXINFO and setting its minimum and maximum size and position to the current size and position. You could also try intercepting WM_MOVING and setting the rect back to its original value.

Share this post


Link to post
Share on other sites
Quote:
Original post by Bob123456
Thank you for replying. I now understand that WM_MOVE means that the user has already moved the window. I now have the following code:

*** Source Snippet Removed ***

This creates a flashy effect, because each time the user moves the window it immediately returns to its proper position. This is fine, but would preventing the window from moving at all be possible?

Quote:
Original post by The Lion King
I believe this problem cannot be solved by the message handler :)

If you wish to just stop user from moving the window. Try playing with the CreateWindowEx() function and its flags :)

That should do the trick ...

If you still can't figure it out ... let me know and I will post the code


Thank you for your post, but no MSDN page gives a flag that would solve this situation.


What you want is a window that does not have a caption associated to it. I think the code below will do just that. No caption should stop the window from moving.


CreateWindowEx(
WS_EX_APPWINDOW,
"MyClassAtomName",
"MyStaticWindow",
WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP | WS_VISIBLE,
nX, nY,
nWidth, nHeight,
NULL,
NULL,
hInstance,
NULL
);

Share this post


Link to post
Share on other sites
Quote:
Original post by Deception666
Quote:
Original post by Bob123456
Thank you for replying. I now understand that WM_MOVE means that the user has already moved the window. I now have the following code:

*** Source Snippet Removed ***

This creates a flashy effect, because each time the user moves the window it immediately returns to its proper position. This is fine, but would preventing the window from moving at all be possible?

Quote:
Original post by The Lion King
I believe this problem cannot be solved by the message handler :)

If you wish to just stop user from moving the window. Try playing with the CreateWindowEx() function and its flags :)

That should do the trick ...

If you still can't figure it out ... let me know and I will post the code


Thank you for your post, but no MSDN page gives a flag that would solve this situation.


What you want is a window that does not have a caption associated to it. I think the code below will do just that. No caption should stop the window from moving.

*** Source Snippet Removed ***


Thank you, Deception666!! That did the trick! Wow, what a wonderful community that surrounds me! GameDev.net was the only place that gave me a working solution. By the way, I don't think that WS_POPUP was necessary, so I removed that.

Once again, thank you Deception666!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement