1.winform打開時實現各種動畫顯示
using System.Runtime.InteropServices;
public class Win32
{
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; //若使用了AW_HIDE標誌,則使窗口向內重疊;若未使用AW_HIDE標誌,則使窗口向外擴展。
public const Int32 AW_HIDE = 0x00010000; //隱藏窗口,缺省則顯示窗口。
public const Int32 AW_ACTIVATE = 0x00020000; //激活窗口。在使用了AW_HIDE標誌後不要使用這個標誌。
public const Int32 AW_SLIDE = 0x00040000; //使用滑動類型。缺省則爲滾動動畫類型。當使用AW_CENTER標誌時,這個標誌就被忽略。
public const Int32 AW_BLEND = 0x00080000; //使用淡出效果。只有當hWnd爲頂層窗口的時候纔可以使用此標誌。
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool AnimateWindow(
IntPtr hwnd, // handle to window
int dwTime, // duration of animation
int dwFlags // animation type
);
}
private void Form_Load(object sender, EventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_BLEND);
}
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_SLIDE | Win32.AW_HIDE | Win32.AW_BLEND);
}