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


Non-movable window

Recommended Posts

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)



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.

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