C# 窗体弹出效果

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace FormTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Win32.AnimateWindow(this.Handle, 1000, Win32.AW_SLIDE | Win32.AW_HOR_POSITIVE);
        }

        private void Form1_Closing(object sender, EventArgs e)
        {
            Win32.AnimateWindow(this.Handle, 1000,  Win32.AW_HIDE | Win32.AW_CENTER);
        }

        public class Win32
        {
            public const Int32 AW_SLIDE =        0x00040000;    // 滑动
            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_BLEND =        0x00080000;    // 淡入淡出
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static extern bool AnimateWindow(
            IntPtr hwnd, // 窗口句柄
            int dwTime,  // 动画时间
            int dwFlags  // 动画类型
            );
        }
    }
}
namespace FormTest
{
    partial class Form1
    {
        /// 
        /// 必需的设计器变量。
        /// 
        private System.ComponentModel.IContainer components = null;

        /// 
        /// 清理所有正在使用的资源。
        /// 
        /// 如果应释放托管资源,为 true;否则为 false。
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// 
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// 
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Consolas", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(89, 128);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(220, 112);
            this.label1.TabIndex = 0;
            this.label1.Text = "这是一个测试窗体\r\n这是一个测试窗体\r\nQode";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(400, 400);
            this.Controls.Add(this.label1);
            this.Name = "Form1";
            this.Text = "Form1";
         
            // 关闭按钮的 “回调函数”
            this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
           
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }
        #endregion

        private System.Windows.Forms.Label label1;
    }
}


你可能感兴趣的:(其他语言)