[DllImport("User32.dll", CharSet = CharSet.Unicode, EntryPoint = "FlashWindowEx")]
private static extern void FlashWindowEx(ref FLASHWINFO pwfi);
public struct FLASHWINFO
{
public UInt32 cbSize;//该结构的字节大小
public IntPtr hwnd;//要闪烁的窗口的句柄,该窗口可以是打开的或最小化的
public UInt32 dwFlags;//闪烁的状态
public UInt32 uCount;//闪烁窗口的次数
public UInt32 dwTimeout;//窗口闪烁的频度,毫秒为单位;若该值为0,则为默认图标的闪烁频度
}
/// <summary>
/// 闪烁类型
/// </summary>
public enum FlashType : uint
{
FLASHW_STOP = 0, //停止闪烁
FALSHW_CAPTION = 1, //只闪烁标题
FLASHW_TRAY = 2, //只闪烁任务栏
FLASHW_ALL = 3, //标题和任务栏同时闪烁
FLASHW_PARAM1 = 4,
FLASHW_PARAM2 = 12,
FLASHW_TIMER = FLASHW_TRAY | FLASHW_PARAM1, //无条件闪烁任务栏直到发送停止标志或者窗口被激活,如果未激活,停止时高亮
FLASHW_TIMERNOFG = FLASHW_TRAY | FLASHW_PARAM2 //未激活时闪烁任务栏直到发送停止标志或者窗体被激活,停止后高亮
}
private void FlashWin()
{
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.hwnd = this.Handle;
fInfo.dwFlags = (uint)FlashType.FLASHW_TRAY;
fInfo.uCount = 5;// UInt32.MaxValue;
fInfo.dwTimeout = 0;
FlashWindowEx(ref fInfo);
}