用2个不同的图片,再使用TIMER控件使2个图片进行切换就行
下面是我从网站上转载的 看下就清楚
Public Class Form1
Inherits System.Windows.Forms.Form
Private m_Icon1 As Icon
Private m_Icon2 As Icon
Private m_bFlag As Boolean
Private m_bShowWnd As Boolean
Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog
Friend WithEvents Button1 As System.Windows.Forms.Button
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
m_bFlag = True
m_bShowWnd = True
Try
m_Icon1 = New Icon("image1.ico") '导入图标文件
m_Icon2 = New Icon("image2.ico")
Catch e As Exception
MessageBox.Show("错误 " + e.Message, "动态系统托盘 - 错误")
MenuItem2.Enabled = False
MenuItem3.Enabled = False
End Try
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
Private components As System.ComponentModel.IContainer
'Required by the Windows Form Designer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu()
Me.MenuItem1 = New System.Windows.Forms.MenuItem()
Me.MenuItem4 = New System.Windows.Forms.MenuItem()
Me.MenuItem2 = New System.Windows.Forms.MenuItem()
Me.MenuItem5 = New System.Windows.Forms.MenuItem()
Me.MenuItem3 = New System.Windows.Forms.MenuItem()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.Label1 = New System.Windows.Forms.Label()
Me.ColorDialog1 = New System.Windows.Forms.ColorDialog()
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem4, Me.MenuItem2, Me.MenuItem5, Me.MenuItem3})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.Text = "动画图标开始"
'
'MenuItem4
'
Me.MenuItem4.Index = 1
Me.MenuItem4.Text = "-"
'
'MenuItem2
'
Me.MenuItem2.Index = 2
Me.MenuItem2.Text = "动画图标结束"
'
'MenuItem5
'
Me.MenuItem5.Index = 3
Me.MenuItem5.Text = "-"
'
'MenuItem3
'
Me.MenuItem3.Index = 4
Me.MenuItem3.Text = "退出程序"
'
'Timer1
'
Me.Timer1.Interval = 500
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(72, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(128, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "动态系统托盘图标实例"
'
'NotifyIcon1
'
Me.NotifyIcon1.ContextMenu = Me.ContextMenu1
Me.NotifyIcon1.Icon = CType(resources.GetObject("NotifyIcon1.Icon"), System.Drawing.Icon)
Me.NotifyIcon1.Text = "动态系统托盘程序"
Me.NotifyIcon1.Visible = True
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(96, 64)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "隐藏窗体"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(280, 117)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.Label1})
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.ShowInTaskbar = False
Me.Text = "动态系统托盘图标"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Timer1.Start()
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Timer1.Stop()
End Sub
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
Application.Exit()
End Sub
Private Sub NotifyIcon1_Disposed(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyIcon1.Disposed
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Not (m_Icon1 Is Nothing) And Not (m_Icon2 Is Nothing) Then '如果两个图标文件都被正确载入
'只要timer1被启动,则在两个图标之间不断进行选择变换,实现动画效果
If m_bFlag = True Then
NotifyIcon1.Icon = m_Icon2
m_bFlag = False
Else
NotifyIcon1.Icon = m_Icon1
m_bFlag = True
End If
End If
End Sub
Private Sub NotifyIcon1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If (m_bShowWnd = True) Then '隐藏主界面
Me.Visible = False
m_bShowWnd = False
Else '显示主界面
Me.Visible = True
m_bShowWnd = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Visible = False
End Sub
Private Sub NotifyIcon1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
Me.Visible = True
m_bShowWnd = True
End Sub
End Class
给予支持!