views:

1853

answers:

4

I know how I do to place a icon in the systray. But what the best method to perform systray icon animation? animated gifs? timers?

Preferentially using C# and/or WPF. Thanks!

+2  A: 

I think the best way to do this is to have multiple small icons which you can continue to change the systray object to the new picture based on the speed and the time.

Suroot
+7  A: 

With a timer, you could do something like

public void timer1_Tick(object sender, EventArgs e)
{
   int framesPerSecond = 5;

   int index = (Environment.TickCount * framesPerSecond / 1000) % 
                animationImgList.Images.Count;

   IntPtr hIcon = ((Bitmap)(imgList.Images[index])).GetHicon();
   notifyIcon.Icon = Icon.FromHandle(hIcon);
}

Of course, you'd want the ticks to happen fast enough for your chosen framesPerSecond

Daniel LeCheminant
+1  A: 

I don't know which language you are writing in, but here is a C++ example: http://www.codeproject.com/KB/shell/ss_trayicon.aspx

goths
I think he mentioned c# a couple of times
benPearce
Oh that one!... that question was edited later. The original one did not have any mention.
goths