自己做了一个窗体动画,可是跳转到本窗体后,窗体动画一完毕,窗体就自动消失关闭了,大家看看怎么回事
代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace flashform
{
    public partial class Form1 : Form
    {
        [DllImportAttribute("user32.dll")]
        private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
        public const Int32 AW_HOR_POSITIVE = 0x00000001;
        public const Int32 AW_HOR_NEGATIVE = 0x00000002;
        public const Int32 AW_VER_POSITIVE = 0x00000004;
        public const Int32 AW_VER_NEGATIVE = 0x00000008;
        public const Int32 AW_CENTER = 0x00000010;
        public const Int32 AW_HIDE = 0x00010000;
        public const Int32 AW_ACTIVATE = 0x00020000;
        public const Int32 AW_SLIDE = 0x00040000;
        public const Int32 AW_BLEND = 0x00080000;
        /*AnimateWindow 函数在 C#中的应用. 
 
       声明方式:          声明
    [DllImportAttribute("user32.dll")]
    private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);         参数说明:          Code
    (1). IntPtr hwnd: 目标窗口的句柄对象, 一般为 this.Handle
    (2). int dwTime: 动画的持续时间, 数值越大动画效果的时间越长
     (3). int dwFlags: 动画效果类型选项, 在C#中声明如下:
     注: 您程序中只声明需要的动画类型即可, 关于每个参数的含义会在后面详细说明
      public const Int32 AW_HOR_POSITIVE = 0x00000001;
      public const Int32 AW_HOR_NEGATIVE = 0x00000002;
      public const Int32 AW_VER_POSITIVE = 0x00000004;
      public const Int32 AW_VER_NEGATIVE = 0x00000008;
      public const Int32 AW_CENTER = 0x00000010;
      public const Int32 AW_HIDE = 0x00010000;
      public const Int32 AW_ACTIVATE = 0x00020000;
      public const Int32 AW_SLIDE = 0x00040000;
      public const Int32 AW_BLEND = 0x00080000;
         动画效果类型详细说明表:      1. AW_SLIDE : 使用滑动类型, 默认为该类型. 当使用 AW_CENTER 效果时, 此效果被忽略      2. AW_ACTIVE: 激活窗口, 在使用了 AW_HIDE 效果时不可使用此效果      3. AW_BLEND: 使用淡入效果      4. AW_HIDE: 隐藏窗口      5. AW_CENTER: 与 AW_HIDE 效果配合使用则效果为窗口几内重叠, 单独使用窗口向外扩展.
    
      6. AW_HOR_POSITIVE : 自左向右显示窗口      7. AW_HOR_NEGATIVE: 自右向左显示窗口      8. AW_VER_POSITVE: 自顶向下显示窗口      9. AW_VER_NEGATIVE : 自下向上显示窗口        */
        public Form1()
        {
            InitializeComponent();
            AnimateWindow(this.Handle, 1000, AW_SLIDE + AW_CENTER);
        }        private void Form1_Load(object sender, EventArgs e)
        {
            AnimateWindow(this.Handle,2000,AW_CENTER+AW_HIDE);
            AnimateWindow(this.Handle,1000,AW_CENTER);
        }
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            AnimateWindow(this.Handle, 500, AW_SLIDE + AW_VER_POSITIVE + AW_HIDE);
        }
        private void btn_Click(object sender, EventArgs e)
        {
            this.Close();
        }    }
}