How can I load an animated gif without using a control?

Posted on 2006-05-15
Last Modified: 2010-04-16
Hi guys,
I'm working with windows form in .net 2k5. I want to load an animated gif without using any control such as PictureBox. Is there any way re-drawing it?
Question by:nhagiaubungbu
    LVL 11

    Expert Comment

    where do you wanna draw it?on a form? on a control?
    LVL 4

    Author Comment

    On a form :)
    LVL 11

    Accepted Solution

    here is an example which comes from the msdn:

    using System;
    using System.Drawing;
    using System.Windows.Forms;

    public class animateImage : Form
        //Create a Bitmpap Object.
        Bitmap animatedImage = new Bitmap("SampleAnimation.gif");
        bool currentlyAnimating = false;
        //This method begins the animation.
        public void AnimateImage()
            if (!currentlyAnimating)
                //Begin the animation only once.
                ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged));
                currentlyAnimating = true;

        private void OnFrameChanged(object o, EventArgs e)
            //Force a call to the Paint event handler.

        protected override void OnPaint(PaintEventArgs e)
            //Begin the animation.
            //Get the next frame ready for rendering.
            //Draw the next frame in the animation.
            e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));

        public static void Main()
            Application.Run(new animateImage());


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now