用户登录
用户注册

分享至

C# 动画窗体(AnimateWindow)的小例子

  • 作者: 寂季19180931
  • 来源: 51数据库
  • 2021-09-04

复制代码 代码如下:

using system;
using system.runtime.interopservices;
using system.windows.forms;

namespace winformtitle
{
    public partial class formtitle : form
    {
        [dllimport("user32.dll", entrypoint = "animatewindow")]
        private static extern bool animatewindow(intptr handle, int ms, int flags);

        public formtitle()
        {
            initializecomponent();
            this.startposition = formstartposition.centerscreen;
        }

        protected override void onload(eventargs e)
        {
            base.onload(e);
            animatewindow(this.handle, 1000, 0x20010);   // 居中逐渐显示。
            //animatewindow(this.handle, 1000, 0xa0000); // 淡入淡出效果。
            //animatewindow(this.handle, 1000, 0x60004); // 自上向下。
            //animatewindow(this.handle, 1000, 0x20004); // 自上向下。
        }

        protected override void onformclosing(formclosingeventargs e)
        {
            base.onformclosing(e);
            animatewindow(this.handle, 1000, 0x10010);    // 居中逐渐隐藏。
            //animatewindow(this.handle, 1000, 0x90000); // 淡入淡出效果。
            //animatewindow(this.handle, 1000, 0x50008); // 自下而上。
            //animatewindow(this.handle, 1000, 0x10008); // 自下而上。
        }
    }
}

软件
前端设计
程序设计
Java相关