Why don't you forward WM_GETMINMAXINFO and clamp the results?
In my illustration of how to make a window resizable in only one direction, commenter Josua asks, “Why don’t you forward
WM_GETMINMAXINFO and clamp the results?” I’m going to assume the question is really “Why don’t you forward
WM_GETMINMAXINFO before clamping the results?” rather than “Why did you bother writing all this code in the first place? Why not simply forward
WM_GETMINMAXINFO and clamp the results?”¹ The answer is that forwarding
WM_GETMINMAXINFO doesn’t do anything. As noted in the documentation, the incoming
MINMAXINFO structure already has the default values on entry. The default handler for the
WM_GETMINMAXINFO message returns without doing anything, since all the default handler does is accept the defaults. So sure, you could forward the message, and then clamp the results, but the forwarding doesn’t accomplish anything.
¹ In case the question really was “Why did you bother writing all this code in the first place…”: Go ahead and delete all the changes aside from the initial version of the
OnGetMinMaxInfo handler. You’ll see the problems called out in the text: The resize arrows appear when the mouse hovers over the corners and the left and right edges. And if you maximize the window onto a secondary monitor, and that monitor’s height is different from the height of the primary monitor, it maximizes to the wrong height.