Holy cow, I wrote a book!
A customer reported that the translucent preview shows by
showed the wrong dimensions for their application window.
"As you can see in the screen shot, the preview is too wide.
Our application window has a maximum width,
but the preview is fully half the width of the screen.
How can we disable the Aero Snap feature?"
giving up so easily?
Sounds like you're throwing the baby out with the bathwater.
To control the size of the preview window used by Aero Snap,
you respond to the same message you've already been responding
to in order to tell Windows the valid range of sizes for your
Start with our
and make the following changes:
void OnGetMinMaxInfo(HWND hwnd, LPMINMAXINFO pmmi)
pmmi->ptMaxTrackSize.x = 400;
// add to WndProc
HANDLE_MSG(hwnd, WM_GETMINMAXINFO, OnGetMinMaxInfo);
We specify in the OnGetMinMaxInfo
the maximum width for the window is 400 pixels.
(In real life, of course, you wouldn't hard-code the width,
but this is just a proof of concept program.)
Since we don't touch ptMaxTrackSize.y,
we impose no additional constraints on the window height
beyond what comes with Windows by default.
Run this program, and use Aero Snap to shove it against the
edges of the screen.
Observe that the Aero Snap preview respects our maximum
I never heard back from the customer, so I assume this simple
solution worked for them.
The fact that they had to ask this question tells me that
they hadn't been handling the WM_GETMINMAXINFO
instead, they were enforcing their window size procedurally
after the window manager already decided on the wrong size.
Either they didn't seem to mind that the maximize and restore
animations showed the window animating to the wrong size,
or they couldn't figure out how to fix that problem either.