在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
C#动态系统托盘图标 利用timer组件定时执行变化。 1 using System; 2 using System.Windows.Forms; 3 4 namespace DynamicStockIcon 5 { 6 public partial class DynamicStockIcon : Form 7 { 8 public DynamicStockIcon() 9 { 10 InitializeComponent(); 11 } 12 13 private void DynamicStockIcon_Load(object sender, EventArgs e) 14 { 15 stocktimer.Interval = 400; 16 } 17 18 #region 本程序声明的变量 19 public static bool flag=false ; 20 #endregion 21 22 23 private void flicker_Click(object sender,EventArgs e) 24 { 25 stocktimer.Enabled = true; 26 27 } 28 29 private void cease_Click(object sender,EventArgs e) 30 { 31 stocktimer.Enabled = false; 32 stockIcon.Icon = Properties.Resources._1; 33 } 34 35 private void stocktimer_Tick(object sender,EventArgs e) 36 { 37 if(flag == false) 38 { 39 stockIcon.Icon = Properties.Resources._1; 40 flag = true; 41 } 42 else 43 { 44 stockIcon.Icon = Properties.Resources._2; 45 flag = false; 46 } 47 } 48 49 50 } 51 }
|
请发表评论