I never knew this, but apparently:
By default, the system reduces a minimized window to the size of its taskbar button and moves the minimized w
Handle WM_SIZE message. If wParam is not SIZE_MAXIMIZED or SIZE_MINIMIZED, keep window size and position in some varibles. Use these variables when window is closed.