Animate notify icon

I have windows form with notify icon. On certain event I want the Icon to animate till user click on it. Then message box should display the message and notify icon should stop animation.
How can I do it?
glowasAsked:
Who is Participating?
 
JoeisanerdConnect With a Mentor Commented:
Create as many icons as you need for the animation in code.
Icon Icon1 = new Icon("icon1.ico");
Icon Icon2 = new Icon("icon2.ico");

Add the notifyIcon to the form, also add a timer
Write an event for the timer so that when it goes off you change the currently displayed icon in notifiyIcon like this.

if( notifyIcon1.Icon == Icon1 )
    notifyIcon1.Icon = Icon2;
else
   notifyIcon1.Icon = Icon1;

This way the icons will switch back and forth whenever the timer goes off. If you want the animation to stop then stop the timer and set the icon to what icon you want.

Just write the mouse click event for the notifyIcon and on that event stop the timer, change icons, display message.
0
 
ptmcompCommented:
Note: Make sure you're using Windows.Forms.Timer (There are 3 timer implementations with different behaviour)
0
 
jimmackCommented:
Can you use a static GIF and an animated GIF and switch between the two as necessary?  You would avoid the need to have lots of .ico files then.
0
 
JoeisanerdCommented:
No you can't use gifs, there icons.  You could however put the icons in a resource file and load the icons from the resource file.
0
 
jimmackCommented:
Never mind, it was just a thought ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.