I have a borderless form and I use the AnimateWindow() method to create animations for opening, closing, etc my Form. I use this code:
[Flags]
enum AnimateWindowFlags
{
AW_HOR_POSITIVE = 0x0000000
AW_HOR_NEGATIVE = 0x00000002,
AW_VER_POSITIVE = 0x00000004,
AW_VER_NEGATIVE = 0x00000008,
AW_CENTER = 0x00000010,
AW_HIDE = 0x00010000,
AW_ACTIVATE = 0x00020000,
AW_SLIDE = 0x00040000,
AW_BLEND = 0x00080000
}
[DllImport("user32.dll")]
static extern bool AnimateWindow(IntPtr hWnd, int time, AnimateWindowFlags flags);
When it comes to closing the form, this code seems to work:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
AnimateWindow(this.Handle, 100, AnimateWindowFlags.AW_BLEND | AnimateWindowFlags.AW_HIDE);
}
However, when opening the form with this code:
private void Form1_Load(object sender, EventArgs e)
{
AnimateWindow(this.Handle, 100, AnimateWindowFlags.AW_BLEND);
}
Nothing seems to happen. After doing some guesses and tests I figured that using the AnimateWindow() method to make the form fade out works, but using it to make the form fade in doesn't do anything (regardless of the time
parameter).
Any ideas?