Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to make System Try Animated Icons and Text of your Application Form in VB.Net

Author: DevASP
Download Source Code : 369_System_tray_animation.zip

This tip will show you how you can make animated icon, animated system tray icon and animated text of form title.

Create a VB.net Application then drag a timer control, Notify icon and three buttons on your form. Firstly create some global variables: 

 

Dim icon1 As New Icon("ac0036-48.ico")

Dim icon2 As New Icon("ac0036-32.ico")

Dim check As Integer = 0

Dim NAMECHECK As Integer = 0

 

Now write code on form load event

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        Button1.Text = "START"

        Button2.Text = "STOP"

        Button3.Text = "EXIT"

        Button1.FlatStyle = FlatStyle.System

        Button2.FlatStyle = FlatStyle.System

        Button3.FlatStyle = FlatStyle.System

 

        Timer1.Interval = 300

        Me.Icon = icon1

 

End Sub

Now write code on timer tick event

 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

 

        If check = 1 Then

            Me.Icon = icon2

            NotifyIcon1.Icon = Me.Icon

            check = 0

        Else

            Me.Icon = icon1

            NotifyIcon1.Icon = Me.Icon

            check = 1

        End If

 

        If NAMECHECK = 0 Then

            Me.Text = "D"

        ElseIf NAMECHECK = 1 Then

            Me.Text = "DE"

        ElseIf NAMECHECK = 2 Then

            Me.Text = "DEV"

        ElseIf NAMECHECK = 3 Then

            Me.Text = "DEVA"

        ElseIf NAMECHECK = 4 Then

            Me.Text = "DEVAS"

        ElseIf NAMECHECK = 5 Then

            Me.Text = "DEVASP"

        End If

        NAMECHECK += 1

 

        If NAMECHECK = 6 Then

            NAMECHECK = 0

        End If

 

End Sub

Now write code on buttons click event

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        NotifyIcon1.Visible = True

        Timer1.Start()

 

End Sub

 

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        Timer1.Stop()

 

End Sub

 

 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

 

        Me.Close()

 

End Sub

Article Comments
And what about cross-thread operation? What you're doing is not safe....you need a begin invoke/end invoke to do "NotifyIcon1.Icon" in "Timer1_Tick" event .

Posted on 1/25/2007 2:55:28 AM by Singwolf

very useful for you code,thanks.

Posted on 2/20/2008 8:28:54 AM by guna

nice!!!

Posted on 3/17/2010 11:31:04 AM by likenoother

Thank you for nice code you provide :)

Posted on 6/20/2010 6:18:19 AM by DarkNight

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to Show Icon of your Application in System Tray

Disclaimer - Privacy
© 2002-2017 DevASP.net