C# winform 右下角快顯視窗結果

來源:互聯網
上載者:User
using System.Runtime.InteropServices;[DllImport("user32")]private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);//下面是可用的常量,按照不合的動畫結果聲明本身須要的private const int AW_HOR_POSITIVE = 0 x0001;//自左向右顯示視窗,該標記可以在遷移轉變動畫和滑動動畫中應用。應用AW_CENTER標記時忽視該標記private const int AW_HOR_NEGATIVE = 0 x0002;//自右向左顯示視窗,該標記可以在遷移轉變動畫和滑動動畫中應用。應用AW_CENTER標記時忽視該標記private const int AW_VER_POSITIVE = 0 x0004;//自頂向下顯示視窗,該標記可以在遷移轉變動畫和滑動動畫中應用。應用AW_CENTER標記時忽視該標記private const int AW_VER_NEGATIVE = 0 x0008;//自下向上顯示視窗,該標記可以在遷移轉變動畫和滑動動畫中應用。應用AW_CENTER標記時忽視該標記該標記private const int AW_CENTER = 0 x0010;//若應用了AW_HIDE標記,則使視窗向內重疊;不然向外擴大private const int AW_HIDE = 0 x10000;//隱蔽視窗private const int AW_ACTIVE = 0 x20000;//啟用視窗,在應用了AW_HIDE標記後不要應用這個標記private const int AW_SLIDE = 0 x40000;//應用滑動類型動畫結果,預設為遷移轉變動畫類型,當應用AW_CENTER標記時,這個標記就被忽視private const int AW_BLEND = 0 x80000;//應用淡入淡出結果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);//設定表單在螢幕右下角顯示    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);}///以下還有第二種方法////// 表單動畫函數 注意:要引用System.Runtime.InteropServices;////// 指定產生動畫的視窗的控制代碼 /// 指定動畫持續的時間 /// 指定動畫類型,可以是一個或多個標誌的組合。 ///[DllImport("user32")]private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);//下面是可用的常量,根據不同的動畫效果聲明自己需要的private const int AW_HOR_POSITIVE = 0x0001;//自左向右顯示視窗,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌private const int AW_HOR_NEGATIVE = 0x0002;//自右向左顯示視窗,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌private const int AW_VER_POSITIVE = 0x0004;//自頂向下顯示視窗,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌private const int AW_VER_NEGATIVE = 0x0008;//自下向上顯示視窗,該標誌可以在滾動動畫和滑動動畫中使用。使用AW_CENTER標誌時忽略該標誌該標誌private const int AW_CENTER = 0x0010;//若使用了AW_HIDE標誌,則使視窗向內重疊;否則向外擴充private const int AW_HIDE = 0x10000;//隱藏視窗private const int AW_ACTIVE = 0x20000;//啟用視窗,在使用了AW_HIDE標誌後不要使用這個標誌private const int AW_SLIDE = 0x40000;//使用滑動類型動畫效果,預設為滾動動畫類型,當使用AW_CENTER標誌時,這個標誌就被忽略private const int AW_BLEND = 0x80000;//使用淡入淡出效果private void FrmMsg_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);//設定表單在螢幕右下角顯示    AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVE | AW_VER_NEGATIVE);}private void FrmMsg_FormClosing(object sender, FormClosingEventArgs e){    AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE);} 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.