Welcome to Atlanta .NET Regular Guys Sign in | Join | Help

Adding animated gifs to Windows Forms (Winforms) applications

Sometimes, the hardest battles I face when programming is when I square off against myself (or something bone-headed I’ve done).  I wanted to add an animated gif to a VB.Net Winform app to indicate that progress was occurring and the user should be patient.  I couldn’t use a progress bar b/c my processing was determined by the number of data records I needed to process and data readers don’t give you a count.  Chris suggested that I return the record count as an output parameter but I was too lazy to deal with that – and I wanted to use Spinny anyway

Meet Spinny – Spinny

Anyway, I grabbed a copy of ReportServer.gif someone had mailed me and added it to the form.  Easy enough, but it wasn’t spinning.  How do I make it spin?  I looked online.  People seemed to have all kinds of advice on how to pick a single frame (or advance frame by frame, or even dynamically generate frames) out of a multi-frame image (animated gif) but no one seemed to know how to get the thing to start spinning.  I looked in the help and tried the System.Drawing.ImageAnimator class but that guy kept telling me that the image’s CanAnimate property was False – my image was not a time-based multi-framed image. 

I couldn’t figure it out.  When I looked at my image in Internet Explorer, it spun.  Nothing I could do programmatically would make it spin.  This was really frustrating, especially b/c I couldn’t find any similar problems online.  I was about to give up when I decided, as a last ditch effort, I’d try in new project.  Blank form, picture box, brand new animated gif I’d downloaded.  I used the PictureBox’s image chooser and picked my new image – guess what?  It was spinning in the PREVIEW window!  Naturally, when I ran the project, the image was animated!  This was what I was looking for!  Simple!  Figuring my image was somehow corrupt, I downloaded it again myself and dropped it into my form.  It worked.  Spinny was now spinning.

— Matt Ranlett

Published 13-01-2006 08:02 by Matt Ranlett
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Atlanta .NET Regular Guys said:


Ok, so let's see where we are. In Post1 I talked about getting an animated gif on the screen to indicate...
January 13, 2006 10:59 AM
 

Atlanta .NET Regular Guys said:


Ok, so let's see where we are. In Post1 I talked about getting an animated gif on the screen to indicate...
January 13, 2006 11:00 AM
 

Alexander Gomez said:

try using gif89.dll to play the gif I used it in vb6 and work fine.
August 1, 2007 4:54 PM
 

pamelakworkoutgirl said:

Hi everyone,

Just passing through and wanted to say hi.
<a href="http://sacredheartdietforreal.blogspot.com/ ">Pam</a>
January 18, 2008 1:30 PM

What do you think?

(required) 
(optional)
(required) 

About Matt Ranlett

One of the two original Atlanta .NET Regular Guys, Matt fills his free time by helping to run several Atlanta area user groups, the Atlanta Code Camps, and works as one of the two INETA co-Vice Presidents of Technology
SkinName:iroha_Blog2
Powered by Community Server, by Telligent Systems