[DllImport("user32.dll")]
static extern bool AnimateWindow(IntPtr hwnd, uint dwTime, uint dwFlags);
Or,
[DllImport("user32")]
static extern bool AnimateWindow(IntPtr hwnd, int time, AnimateWindowFlags flags);
<DllImport("user32.dll")> _
Shared Function AnimateWindow(ByVal hwnd As IntPtr, ByVal dwTime As UInteger, ByVal dwFlags As UInteger) As Boolean
End Function
Or,
<DllImport("user32.dll")> _
Shared Function AnimateWindow(ByVal hwnd As IntPtr, ByVal time As Integer, ByVal flags As AnimateWindowFlags) As Boolean
End Function
AnimateWindowFlags can be used for the dwFlags parameter.
You will need the AnimateWindowFlags for this to work correctly. Here they are:
Public Enum AnimateWindowFlags
AW_HOR_POSITIVE = &H1
AW_HOR_NEGATIVE = &H2
AW_VER_POSITIVE = &H4
AW_VER_NEGATIVE = &H8
AW_CENTER = &H10
AW_HIDE = &H10000
AW_ACTIVATE = &H20000
AW_SLIDE = &H40000
AW_BLEND = &H80000
AW_DURATION_DEFAULT = 200
End Enum
To get an animation to run in reverse, to say, animate the window closing use some thing like:
Dim f2 As Form2
f2 = New Form2
AnimateWindow(f2.Handle, 1000, AnimateWindowFlags.AW_VER_NEGATIVE Or AnimateWindowFlags.AW_SLIDE or AnimateWindowFlags.AW_HIDE)
f2.Show()
The AW_HIDE will make any of the animations run in reverse.
This assumes that the AnimateWindow function is declared inside class User32
Form2 f2 = new Form2();
AnimateWindow( f2.Handle, 1000, (uint) AnimateWindowFlags.AW_VER_NEGATIVE |
(uint) AnimateWindowFlags.AW_SLIDE );
f2.Show();
Public Declare Auto Function AnimateWindow Lib "user32" (ByVal hwnd As IntPtr, ByVal time As Integer, ByVal flags As AnimateWindowFlags) As Boolean
Dim f2 As Form2
f2 = New Form2
AnimateWindow(f2.Handle, 1000, AnimateWindowFlags.AW_VER_NEGATIVE Or AnimateWindowFlags.AW_SLIDE)
f2.Show()