Question : Picture box -- gif images problem

hi
I am using a gif image in picture box vb dot net.
It contains one cycle loop.
If I open that gif image in IE means ,the animation starts and stops for one cycle.
But if i use the same gif image in picture box vb dot net means ,the animation is
continiously happening.
I need the animation starts and stops for one cycle.

Answer : Picture box -- gif images problem

Try following code. It will stop after one cycle loop.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
Public Class Form2 
  Dim gif As Bitmap = New Bitmap("C:\arrived.gif") 

  
  Dim intFreamCount As Long 
  Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
    If ImageAnimator.CanAnimate(gif) Then
      ImageAnimator.Animate(gif, New EventHandler(AddressOf gif_FrameChanged))
    End If 
  End Sub 
  Private Sub gif_StoAnimation(ByVal sender As Object, ByVal e As EventArgs)
    MessageBox.Show("Done")
  End Sub 
  Private Sub gif_FrameChanged(ByVal sender As Object, ByVal e As EventArgs)
    intFreamCount += 1
    If intFreamCount > gif.GetFrameCount(FrameDimension.Time) Then
      ImageAnimator.StopAnimate(gif, New EventHandler(AddressOf gif_StoAnimation))
    Else
      Me.Invalidate()
    End If 
  End Sub 
  Private Sub AnimationForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
    ImageAnimator.UpdateFrames(gif)
    Dim g As Graphics = e.Graphics
    Dim rect As Rectangle = Me.ClientRectangle
    rect.Height = rect.Height
    g.DrawImage(gif, rect)
  End Sub 
End Class
Random Solutions  
 
programming4us programming4us