You can display animated GIFs by setting the Image property of a Button, PictureBox, Label, or other control to the GIF file. (If you display one in a Form‘s BackgroundImage property, you don’t get the animation.)
There are a couple of ways to change GIFs at runtime.
First, you can add the GIF as a resource. Open the Project menu and select Properties at the bottom. On the Resources tab, open the Add Resource dropdown and select Add Existing File. Browse to the GIF and click Open.
Now you can use the GIF resource as in:
picGif.Image = howto_display_animated_gif.Properties.Resources.puppy;
You can also load GIFs from a file as in the following code.
lblGif.Image = Image.FromFile(filename + "alien.gif");
This program uses resources to change GIFs when you click on its Button or PictureBox. It loads GIFs from files when you click its Label.



I have created a DLL which can display an animated GIF in a window of a dialog box, which also works for Visual C++.
Do you want to post a link?
This is the link to a complete project, sources included, which contains this DLL and uses it:
The principle is quite simple: The user loads an animated GIF by calling a procedure “LoadGif”, in which he gives the full pathname of the GIF.
The procedure returns a pointer to a structure which allows to handle the GIF (which contains the sizes of the GIF, its number of pictures, its temporizations and an array of raw bitmaps representing the pictures of the GIF).
The user must keep this pointer, it represents his Gif; when he has finished using the Gif, he calls a procedure FreeGif with this pointer.
Then he has a whole set of procedures which allow to handle this Gif in various ways, to which he gives the pointer of the GIF and parameters.
He can display any picture of the GIF in a window of a dialog box, and he can also automatically sequence the pictures of the GIF.
In order to automatically sequence the pictures of the GIF, either a manual way or an automatic way can be used.
The manual way consists in attributing a Timer event to the GIF, and arming the timer on this event; each time this event elapses in the timer, the user calls a procedure of the DLL allowing to display the next picture of the gif, and this procedure returns the temporization to display this picture, and the user rearms the timer event with this temporization.
The automatic way is simpler to use: The user just calls a procedure to make the DLL automatically periodically display the pictures of the GIF; in that case the timer of the project is not used, the DLL starts a process which takes care of the automatic sequential display of the pictures; the user does not release the context it gives to the procedure of the DLL which makes the automatic sequential display and in which the process started by the DLL displays the pictures of the Gif, for the DLL releases it itself when the procedure to stop the automatic display is called.
In the previous version, there only was the manual way to sequence the display of the pictures of the GIF; I have recently added the automatic way, to simplify the use of the animated GIF (and it runs more smoothly).
I am a professional computer engineer.
Could you give a feedback to my last comment, please?
Well it’s a long comment. It would be better to have that information on your site along with the link. I can’t really do much with the example, though because it’s C++ not C# and it includes compiled object files and executables. I only look at C# source code. (And I don’t have the time to really do a good job on such a big example.)
I more often deal with C++ than with C#; do you mean that I should show a sample project in C# using it?
Well, you don’t have to, but people on this site might be more interested that way. But really if you want other people to use it you should post it on your site so people can find it.
It is already on my site.
http://www.angelfire.com/moon2/xpascal/Applications/GifDemo.Zip