using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;namespace LiBo.FlashWindow
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
int flash; private System.Windows.Forms.Timer tmr;
private System.ComponentModel.IContainer components; public Form1()
{
InitializeComponent();
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tmr = new System.Windows.Forms.Timer(this.components);
// 
// tmr
// 
this.tmr.Enabled = true;
this.tmr.Interval = 1000;
this.tmr.Tick += new System.EventHandler(this.tmr_Tick);
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "闪烁显示指定窗口"; }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} /// <summary>
/// 闪烁显示指定窗口。
/// 这意味着窗口的标题和说明文字会发生变化,似乎从活动切换到非活动状态、或反向切换。
/// 通常对不活动的窗口应用这个函数,引起用户的注意。
/// </summary>
/// <param name="hwnd">要闪烁显示的窗口的句柄</param>
/// <param name="bInvert">TRUE(非零)表示切换窗口标题;FALSE返回最初状态</param>
/// <returns>如窗口在调用前处于活动状态,则返回TRUE(非零)</returns>
[DllImport("user32.dll")]
public static extern int FlashWindow (
int hwnd,
int bInvert
); private void tmr_Tick(object sender, System.EventArgs e)
{
flash = (flash == 1 ? 0 : 1);
FlashWindow(this.Handle.ToInt32(), flash);
}
}
}