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.

Comments (4)
  1. anonymouscommenter says:

    That's a remarkably timely reply (post, not comment), compared to your usual post queue length.

  2. SimonRev says:

    Raymond will occasionally make blog posts in response to comments or other external stimuli.  I remember a year or two ago he did a post about the blue screen of death which got picked up by the media and Raymond turned it into blue screen week to clarify misconceptions and elaborate on a topic that was of obvious interested to everyone.

  3. anonymouscommenter says:

    Indeed no point in forwarding the message for doing nothing. I probably spent too long at high level and missed something because the frameworks handle it; yet I wonder how many programs got broke by this one now because of 4:3 -> 16:9.

  4. anonymouscommenter says:

    The industry went more like:

    4:3 -> 5:4 -> 16:10 -> 16:9

    A good developer fix bugs at first occurrence, other developers still have them in their code.

Comments are closed.

Skip to main content