Atlanta .NET Regular Guys

Community Blog for two guys in Atlanta that focus on Microsoft and Community.

Quick About

This is the community blog for Brendon Schwartz and Matt Ranlett.  If you want to see their technical posts visit http://www.sharepointguys.com

Back To DevCow

Recent Posts

Tags

Email Notifications

    Archives

    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

    Posted: 01-13-2006 8:02 AM by Matt Ranlett | with 3 comment(s)
    Filed under:

    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

    Svintuss said:

    Very big thanks. I was taken same problem. And it was corrupted image too.

    # August 8, 2008 8:28 AM