Share via


gif animation is not working

Question

Tuesday, October 7, 2008 1:05 PM

I made this: 

 

           Panel animacija = new Panel(); //animacija
          
            animacija.Name = "animacija";
            animacija.Size = new Size(105,80);
            animacija.Location = PointToClient(animacija.PointToScreen(new Point(x_pozicija,y_pozicija))); 
           animacija.BackColor = System.Drawing.Color.Aqua;
          
           animacija.BackgroundImage = ((System.Drawing.Image.FromFile(Application.StartupPath + @"\Resources\world.gif")));
               
            panel1.Controls.Add(animacija);
 
When i click on panel it shows me this picture, but problem is that it is gif animation and it shoud move? why is not working? it shows only one frame of animation 

  

All replies (2)

Wednesday, October 8, 2008 11:22 AM ✅Answered | 1 vote

you are setting the gif as background of panel thats why it is not animating. you need to add a picture box in the panel control and then set the image file of that picture box to your gif .

Hope it will help you.

Regards,


Haider Raza Software Engineer, ZABSolutions. MCP(C#)


Wednesday, October 8, 2008 12:24 PM ✅Answered | 1 vote

Hi

Do it something like this.. here picGifImage is a PictureBox control.. :))

         Panel animacija = new Panel(); //animacija
          
              animacija.Name = "animacija";
               animacija.Size = new Size(105,80);
               animacija.Location = PointToClient(animacija.PointToScreen(new Point(x_pozicija,y_pozicija))); 
              animacija.BackColor = System.Drawing.Color.Aqua;
        animacija.Controls.Add(this.picGifImage);

                        
                        imgGIFImage = Image.FromFile(\Some path);
                        this.picGifImage.Image = imgGIFImage ;                       
                        this.picGifImage.Size = imgGIFImage .Size;
                        this.picGifImage.SizeMode = PictureBoxSizeMode.CenterImage;

This will definitly show you the Animated GIF Image..

Cheers by Anand Ranjan


Developer