Why doesn’t the MoveWindow function generate the WM_GETMINMAXINFO message?

Raymond Chen

Commenter Phil Quirk asks why calling MoveWindow does not result in a WM_GETMINMAXINFO message being sent to validate the moved window size.

Well, because you moved it after all. You’re being trusted to respect your own rules. After all, if you didn’t want the window to be wider than 200 pixels, you shouldn’t have passed nWidth=300, right?

The WM_GETMINMAXINFO message is for obtaining minimum and maximum sizing information when the sizes were chosen by a means outside the application’s control, such as when you said “I’ll let you choose the window size (CW_USEDEFAULT)” or when the user grabbed the corner of the window and started dragging it around. But if you yourself changed the window size, then the window manager assumes that you know what you’re doing.

If you don’t trust yourself to follow your own rules, you can intercept the attempt to change the window size by handling the WM_WINDOWPOSCHANGING message.

0 comments

Discussion is closed.

Feedback usabilla icon