以软件【银行业会计人员技能训练系统】为例,C#如何实现系统任务栏托盘菜单(图标)闪烁?
方法如下:
1、需要增加一个timer控件,增加菜单【闪烁】
2、菜单【闪烁】的相关代码如下:
private Icon fa = Properties.Resources.favicon; private Icon bl = Properties.Resources.blank; private bool _status = true; private void 闪烁ToolStripMenuItem_Click(object sender, EventArgs e) { switch (闪烁ToolStripMenuItem.Text) { case "开启闪烁": timer1.Enabled = true; timer1.Start(); 闪烁ToolStripMenuItem.Text = "关闭闪烁"; break; case "关闭闪烁": timer1.Enabled = false; timer1.Stop(); 闪烁ToolStripMenuItem.Text = "开启闪烁"; break; } }
3、双击timer控件,增加如下代码:
if (_status==true) { notifyIcon1.Icon = Properties.Resources.favicon; } else { notifyIcon1.Icon = Properties.Resources.blank; } _status = !_status;
4、timer1控件的interval属性值设置为“500”
如此即可实现系统托盘菜单(图标)闪烁。