While working on OnTopReplica I needed a way to constrain the aspect ratio of the "cloned" window. Since the live thumbnails created using the DWM API cannot be manipulated and always maintain the aspect of the original window, it makes sense to limit the user's choices in resizing the window, in order to fit the window to the cloned thumbnail automatically.
Much like in the case of media players, where video files have a certain aspect ratio (let's ignore that this ratio can usually be changed by the user). If the video doesn't fit inside the player window, black bars are added on top and bottom or on the sides. Limiting the user's resizing options in this case actually improves the interface experience because a tedious task is handled directly (like searching the right size of the window to reduce the black bars).
In Windows Forms you have two options to react to resize events of the window: the OnResize event and the couple OnResizeBegin and OnResizeEnd. The problem of those two methods is that they both run after the window has been resized. That is, after the window received the WM_SIZE message (in Win32 terms). You can force the window to adopt a correct size after receiving one of those events.
This would work, if it weren't for the option "Show window contents while resizing" (added a long way back in Windows 98, more or less). That option (which is usually on by default) causes the window to generate a lot of WM_SIZE messages while it is being resized. If you react by changing the size on each event, the result is an extremely jerky window that jumps back and forth while the users tries to resize it. And the contents of the window flicker awfully as a result.



