用API函数使程序标题栏闪烁

这个功能和腾讯的QQ聊天工具在聊天的时候当有新的消息来的时候是一样的,在任务栏上闪烁。

工作的原理很简单,就是用到timer控件调用API函数就可以了。

#region "声明API函数"
[DllImport(
"user32", EntryPoint = "FlashWindow")]
public static extern void FlashWindow(int hwnd, bool bInvert);
#endregion

timer的Tick事件调用声明的API函数

#region "时间的Tick事件"
private void timer1_Tick(object sender, EventArgs e)
{
FlashWindow(
this.Handle.ToInt32(), true);
}

为了显示演示效果我是在窗体的加载时让timer控件开始工作的,当然你可以根据实际的情况运用在合适的位置上也会是很不错的选择。

timer1.Start();//让timer组件开始工作
timer1.Interval = 1000;
原文地址:https://www.cnblogs.com/wangsaiming/p/2077764.html