AnimateWindow will fail in the following situations:
(1) The window uses the window region.
(2) The window is already visible and you are trying to show the window.
(3) The window is already hidden and you are trying to hide the window.
So, it's need not to use a boolean variable to indicate the first running of AnimateWindow. But if you use it, it will be OK.