Jump to content
  • Advertisement

Archived

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

atjs

Non-movable window

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

What''s the window style/setting required to make a window non-movable? (Win32, C++)

Share this post


Link to post
Share on other sites
Advertisement
I don''t know about a non-removable window, but you can make it stay put by waiting for a WM_MOVE event and then use the MoveWindow function to move it back to place.

Share this post


Link to post
Share on other sites
To prevent the user from moving the window via the 'Title Bar' you can write the following into your window's 'Window Procedure'...


switch (message_id)
{

...

case WM_NCLBUTTONDOWN:

if (HTCAPTION == word_param)
{

return 0;

}

return DefWindowProc (window_handle, message_id, word_param, long_param);

...

}


Basically what you're doing is checking to see if the user tries to grab the title bar to move the window, if they do return without the message making it to the window's default processing, else pass it own to the window's default processing. You try to grab the window's title bar, it won't budge(sp?). It won't even flinch so to speak.

Handling the move command of the window's system menu can be handled in a similar fashion, I believe. You'd need to capture the WM_SYSCOMMAND message and look for SC_MOVE in the WPARAM. I haven't tried this one yet but the first method (for the title bar) works perfectly. Anywho, I hope that helps some. Later.

Edit:
Scratch the part about the 'System Menu' move command. You can actually just remove the 'Move' option from your window's system menu all together.

Just remember this when trying to alter a window's default behavour. There's a message that has to pass through YOUR window procedure before it get to the DefWindowProc() to cause the default behavour. And those messages will often spawn other messages and so on. So if you can find the message that causes the behavour you want to change, you can coerce it, maim it, slap it around, or just plain kill it, and, in doing so, bend Windows to your benevolent will.

[edited by - microdot on January 18, 2003 5:13:56 AM]

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.

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

Sign me up!