C#如何让notifyIcon闪烁

来源:互联网 发布:淘宝女童模特图片 编辑:程序博客网 时间:2024/06/06 16:05

最近在写一个网络提醒程序,想让有消息到达时,能够让任务栏图标闪烁,类似QQ消息提醒一样,这里用到vs中的NotifyIcon组件,还有定时器组件Timer

首先要有两个图标图像,一个最好是透明的,blank.ico和striped.ico,还要有一个bool类型的变量

        private Icon blank = Resources.blank;        private Icon striped = Resources.striped;        private bool blink = false;

然后,在Timer组件的Tick事件中中添加如下代码:

        private void blinkTimer_Tick(object sender, EventArgs e)        {            if (!blink)            {                this.notifyIcon.Icon = striped;            }            else            {                this.notifyIcon.Icon = blank;            }            blink = !blink;        }

然后再Form_Load事件中设置:

        private void MainForm_Load(object sender, EventArgs e)        {            this.blinkTimer.Enabled = true;        } 

代码下载地址:http://download.csdn.net/detail/henulwj/5483941