本文實例講述了C# winform實現(xiàn)右下角彈出窗口結(jié)果的方法。分享給大家供大家參考,具體如下:
using System.Runtime.InteropServices;[DllImport("user32")]private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);//下面是可用的常量,按照不合的動畫結(jié)果聲明本身須要的private const int AW_HOR_POSITIVE = 0 x0001;//自左向右顯示窗口,該標記可以在遷移轉(zhuǎn)變動畫和滑動動畫中應(yīng)用。應(yīng)用AW_CENTER標記時忽視該標記private const int AW_HOR_NEGATIVE = 0 x0002;//自右向左顯示窗口,該標記可以在遷移轉(zhuǎn)變動畫和滑動動畫中應(yīng)用。應(yīng)用AW_CENTER標記時忽視該標記private const int AW_VER_POSITIVE = 0 x0004;//自頂向下顯示窗口,該標記可以在遷移轉(zhuǎn)變動畫和滑動動畫中應(yīng)用。應(yīng)用AW_CENTER標記時忽視該標記private const int AW_VER_NEGATIVE = 0 x0008;//自下向上顯示窗口,該標記可以在遷移轉(zhuǎn)變動畫和滑動動畫中應(yīng)用。應(yīng)用AW_CENTER標記時忽視該標記該標記private const int AW_CENTER = 0 x0010;//若應(yīng)用了AW_HIDE標記,則使窗口向內(nèi)重疊;不然向外擴大private const int AW_HIDE = 0 x10000;//隱蔽窗口private const int AW_ACTIVE = 0 x20000;//激活窗口,在應(yīng)用了AW_HIDE標記后不要應(yīng)用這個標記private const int AW_SLIDE = 0 x40000;//應(yīng)用滑動類型動畫結(jié)果,默認為遷移轉(zhuǎn)變動畫類型,當應(yīng)用AW_CENTER標記時,這個標記就被忽視private const int AW_BLEND = 0 x80000;//應(yīng)用淡入淡出結(jié)果private void Form1_Load(object sender, EventArgs e){ int x = Screen.PrimaryScreen.WorkingArea.Right - this.Width; int y = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height; this.Location = new Point(x, y);//設(shè)置窗體在屏幕右下角顯示 AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE);}private void Form1_FormClosing(object sender, FormClosingEventArgs e){ AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE);}
希望本文所述對大家C#程序設(shè)計有所幫助。
新聞熱點
疑難解答