using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WMS.UI.Basic { public partial class messages : Form { [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags); /// /// 得到当前活动的窗口 /// /// [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern System.IntPtr GetForegroundWindow(); public messages(int type,string text) { InitializeComponent(); this.Location=new Point( Screen.GetWorkingArea(this).Width/2-this.Width/2, 50); if (type == 1) { this.BackColor = Color.FromArgb(240, 249, 235); label1.ForeColor = Color.FromArgb(103, 194, 109); label1.Text = text; } else { this.BackColor = Color.FromArgb(254, 240, 240); label1.ForeColor = Color.FromArgb(245, 108, 108); label1.Text = text; } SetWindowPos(GetForegroundWindow(), -1, 0, 0, 0, 0, 1 | 2); } private void timer1_Tick_1(object sender, EventArgs e) { timer1.Enabled = false; for (int i = 0; i <= this.Height; i++) { Point p = new Point(this.Location.X, Location.Y -i); this.PointToScreen(p); this.Location = p; System.Threading.Thread.Sleep(10); } this.Close(); } } }