Results 1 to 2 of 2

Thread: insert and display gif files

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Location
    NeverNeverLand
    Posts
    8

    insert and display gif files

    Hi there. I have a problem inserting and displaying gif files in my forms of Visual Basic 6. Most of the files constists of 9 frames. Even i managed to loop all the nine frames is always stucks at the last frame. Could you tell me an efficient way of displaying gif files on VB forms. Cheers.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Here's a very simple method that uses the WebBrowser control to display an Animated GIF with no hassle.

    Add a Picturebox, WebBrowser, Command Button and CommonDialog Control to a Form:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     On Error GoTo Cancel_Error
    5.    
    6.     With CommonDialog1
    7.         .Filter = "GIFs|*.gif"
    8.         .ShowOpen
    9.        
    10.         Call OpenGif(.FileName)
    11.     End With
    12.    
    13. Cancel_Error:
    14. End Sub
    15.  
    16. Private Sub OpenGif(ByVal sFile As String)
    17.     ' Place the WebBrowser control within a Picturebox
    18.     ' So we cancover the Scrollbars
    19.     Set WebBrowser1.Container = Picture1
    20.     ' Set the Picturebox ScaleMode to Pixels
    21.     Picture1.ScaleMode = vbPixels
    22.     ' Make the Picturebox Resize to Fit a picture loaded into it.
    23.     Picture1.AutoSize = True
    24.     ' Load a Static image of the GIF into the Picturebox, just
    25.     ' to get it's dimensions.
    26.     Picture1 = LoadPicture(sFile)
    27.     ' Reposition the Webbrowser control within the Picturebox
    28.     ' So that only the GIF will be visible witin the Picturebox area.
    29.     WebBrowser1.Move -12, -17, Picture1.ScaleWidth + 50, Picture1.ScaleHeight + 50
    30.     ' Load the GIF into the WebBrowser Control which supports Animated GIFs.
    31.     WebBrowser1.Navigate2 sFile
    32. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width