May 13th, 2015

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_GET­MIN­MAX­INFO and clamp the results?” I’m going to assume the question is really “Why don’t you forward WM_GET­MIN­MAX­INFO before clamping the results?” rather than “Why did you bother writing all this code in the first place? Why not simply forward WM_GET­MIN­MAX­INFO and clamp the results?”¹ The answer is that forwarding WM_GET­MIN­MAX­INFO doesn’t do anything. As noted in the documentation, the incoming MIN­MAX­INFO structure already has the default values on entry. The default handler for the WM_GET­MIN­MAX­INFO 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 On­Get­Min­Max­Info 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.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.