登陆窗体显示动态效果

来源:互联网 发布:邢台seo外包 编辑:程序博客网 时间:2024/05/17 23:35

/// <summary>

    ///登陆窗体动画效果

    /// </summary>

    public class AnimateWindowFrom

    {

        [System.Runtime.InteropServices.DllImport("user32")]

        private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);

        const int AW_HOR_POSITIVE = 0x0001;

        const int AW_HOR_NEGATIVE = 0x0002;

        const int AW_VER_POSITIVE = 0x0004;

        const int AW_VER_NEGATIVE = 0x0008;

        const int AW_CENTER = 0x0010;

        const int AW_HIDE = 0x10000;

        const int AW_ACTIVATE = 0x20000;

        const int AW_SLIDE = 0x40000;

        const int AW_BLEND = 0x80000;

 

 

        /// <summary>

        /// 窗体由中心点放大

        /// </summary>

        /// <param name="hwnd"></param>

        public static void WindowZoomIn(IntPtr hwnd)

        {

            AnimateWindow(hwnd, 1000, AW_CENTER | AW_ACTIVATE);

        }

        /// <summary>

        /// 窗体由下往上收缩

        /// </summary>

        /// <param name="hwnd"></param>

        public static void WindowZoomOut(IntPtr hwnd)

        {

            AnimateWindow(hwnd, 1000, AW_SLIDE | AW_HIDE | AW_VER_NEGATIVE);

        }

}

 

 

2。动态窗体

/// <summary>

        /// 窗体启动

         /// </summary>

        /// <param name="sender"></param>

        /// <param name="e"></param>

        private void Form1_Load(object sender, EventArgs e)

        {

            //窗体由中心向四周放大

            AnimateWindowFrom.WindowZoomIn(this.Handle);

        }

 

        /// <summary>

        /// 窗体关闭

         /// </summary>

        /// <param name="sender"></param>

        /// <param name="e"></param>

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)

        {

            //窗体由下往上伸缩

            AnimateWindowFrom.WindowZoomOut(this.Handle);

        }

原创粉丝点击