c# 动画
利用windows api 来实现软件启动动画。
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 PatentSourceUpLoadTool
{
public partial class Form1 : Form
{
[DllImportAttribute("user32.dll")]
private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
public Form1()
{
this.FormBorderStyle = FormBorderStyle.None;
this.StartPosition = FormStartPosition.CenterScreen;
InitializeComponent();
this.BackgroundImage = Image.FromFile("test.jpg");
AnimateWindow(this.Handle, 1000, AW_SLIDE + AW_CENTER);
}
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;
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
AnimateWindow(this.Handle, 500, AW_SLIDE + AW_VER_POSITIVE + AW_HIDE);
}
private void Form1_Load(object sender, EventArgs e)
{
FrmLoad MySplashForm = new FrmLoad();
MySplashForm.StartPosition = FormStartPosition.CenterScreen;
this.Visible = false;
MySplashForm.ShowDialog();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PatentSourceUpLoadTool
{
public partial class FrmLoad : Form
{
public FrmLoad()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
this.BackgroundImage = Image.FromFile("test.jpg");
this.timer1.Start();
this.timer1.Interval = 500;
label1.Text = "欢迎使用此软件,正在加载中……";
}
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
Global.FRMPATENT = new FrmPatent();
Global.FRMPATENT.Show();
Global.FRMPATENT.StartPosition = FormStartPosition.CenterScreen;
this.timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Close();
}
}
}
浙公网安备 33010602011771号