Winform 窗体淡出淡入效果

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;//窗体效果需要该包

namespace 软件项目管理系统
{
  public partial class LoginForm : Form
  {
    //窗体弹出或消失效果
    [DllImport("user32.dll", EntryPoint = "AnimateWindow")]
    private static extern bool AnimateWindow(IntPtr handle, int ms, int flags);
    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;

  public LoginForm()
  {
    InitializeComponent();

    //窗体弹出效果
    AnimateWindow(this.Handle, 300, AW_CENTER);
  }

 

  //“关闭按钮”事件
  private void button1_Click(object sender, EventArgs e)
  {
    //窗体弹出效果
    AnimateWindow(this.Handle, 300, AW_HIDE + AW_CENTER);

    Application.Exit();
  
  }
}

posted @ 2017-08-30 09:43  viu  阅读(396)  评论(0编辑  收藏  举报