title: How do I seamlessly call MoveWindow on a maximized window in Windows?
body: <p>I have a C# application that is attempting to create a customizable version of <a href="https://support.microsoft.com/en-us/help/4027324/windows-snap-your-windows" rel="nofollow noreferrer">Windows's Snap</a> functionality. I primarily use the native functions <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633534(v=vs.85).aspx" rel="nofollow noreferrer">MoveWindow</a> and <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633549(v=vs.85).aspx" rel="nofollow noreferrer">ShowWindowAsync</a>. I also use <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms633518(v=vs.85).aspx" rel="nofollow noreferrer">GetWindowPlacement</a> to determine maximized/normal/minimized state.</p>
  
  <p>I can seamlessly snap a "normal" window around to my user definable frames. The window instantly snaps to new desired position and size.</p>
  
  <p>The problem is when I transition from maximized to normal. If I only call MoveWindow then the window snaps to my desired position and size. However the window still thinks it's "maximized" which causes attempts to re-maximize to fail.</p>
  
  <p>However if I call <code>ShowWindowAsync(wnd, SW_SHOWNORMAL)</code> followed by <code>MoveWindow(wnd, x, y, width, height, true)</code> it causes the maximized window to animate to it's old position then snap to its new position. This is very jarring and unpleasant. Attempting to flip the call order or use <code>ShowWindow</code> instead of <code>ShowWindowAsync</code> does not help.</p>
  
  <p>The answer to this question <em>might</em> be to disable the animation. I have not found a clean way to do that.</p>