C#实现动态图标闪烁显示的示例代码

  partial class Form1

  {

  ///

  /// 必需的设计器变量。

  ///

  private System.ComponentModel.IContainer components = null;

  ///

  /// 清理所有正在使用的资源。

  ///

  /// 如果应释放托管资源,为 true;否则为 false。

  protected override void Dispose(bool disposing)

  {

  if (disposing && (components != null))

  {

  components.Dispose();

  }

  base.Dispose(disposing);

  }

  #region Windows 窗体设计器生成的代码

  ///

  /// 设计器支持所需的方法 - 不要

  /// 使用代码编辑器修改此方法的内容。

  ///

  private void InitializeComponent()

  {

  this.components = new System.ComponentModel.Container();

  System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));

  this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);

  this.timer1 = new System.Windows.Forms.Timer(this.components);

  this.txtAdd = new System.Windows.Forms.TextBox();

  this.button1 = new System.Windows.Forms.Button();

  this.label1 = new System.Windows.Forms.Label();

  this.groupBox1 = new System.Windows.Forms.GroupBox();

  this.button2 = new System.Windows.Forms.Button();

  this.groupBox1.SuspendLayout();

  this.SuspendLayout();

  //

  // notifyIcon1

  //

  this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));

  this.notifyIcon1.Visible = true;

  //

  // timer1

  //

  this.timer1.Enabled = true;

  this.timer1.Interval = 500;

  this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

  //

  // txtAdd

  //

  this.txtAdd.Location = new System.Drawing.Point(145, 36);

  this.txtAdd.Name = "txtAdd";

  this.txtAdd.Size = new System.Drawing.Size(193, 21);

  this.txtAdd.TabIndex = 0;

  //

  // button1

  //

  this.button1.Location = new System.Drawing.Point(103, 96);

  this.button1.Name = "button1";

  this.button1.Size = new System.Drawing.Size(75, 23);

  this.button1.TabIndex = 1;

  this.button1.Text = "发送消息";

  this.button1.UseVisualStyleBackColor = true;

  this.button1.Click += new System.EventHandler(this.button1_Click);

  //

  // label1

  //

  this.label1.AutoSize = true;

  this.label1.Location = new System.Drawing.Point(26, 39);

  this.label1.Name = "label1";

  this.label1.Size = new System.Drawing.Size(113, 12);

  this.label1.TabIndex = 2;

  this.label1.Text = "输入对方主机地址:";

  //

  // groupBox1

  //

  this.groupBox1.Controls.Add(this.button2);

  this.groupBox1.Controls.Add(this.button1);

  this.groupBox1.Controls.Add(this.label1);

  this.groupBox1.Controls.Add(this.txtAdd);

  this.groupBox1.Location = new System.Drawing.Point(13, 13);

  this.groupBox1.Name = "groupBox1";

  this.groupBox1.Size = new System.Drawing.Size(353, 154);

  this.groupBox1.TabIndex = 3;

  this.groupBox1.TabStop = false;

  this.groupBox1.Text = "发送消息";

  //

  // button2

  //

  this.button2.Location = new System.Drawing.Point(184, 96);

  this.button2.Name = "button2";

  this.button2.Size = new System.Drawing.Size(75, 23);

  this.button2.TabIndex = 3;

  this.button2.Text = "停止闪动";

  this.button2.UseVisualStyleBackColor = true;

  this.button2.Click += new System.EventHandler(this.button2_Click);

  //

  // Form1

  //

  this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

  this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

  this.ClientSize = new System.Drawing.Size(380, 182);

  this.Controls.Add(this.groupBox1);

  this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;

  this.MaximizeBox = false;

  this.MinimizeBox = false;

  this.Name = "Form1";

  this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

  this.Text = "动态托盘图标";

  this.Load += new System.EventHandler(this.Form1_Load);

  this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);

  this.groupBox1.ResumeLayout(false);

  this.groupBox1.PerformLayout();

  this.ResumeLayout(false);

  }

  #endregion

  private System.Windows.Forms.NotifyIcon notifyIcon1;

  private System.Windows.Forms.Timer timer1;

  private System.Windows.Forms.TextBox txtAdd;

  private System.Windows.Forms.Button button1;

  private System.Windows.Forms.Label label1;

  private System.Windows.Forms.GroupBox groupBox1;

  private System.Windows.Forms.Button button2;

  }