Solved

Animated GIF in Picture Box

Posted on 2004-08-04
4
469 Views
Last Modified: 2008-03-04
Hi, I need a way to display an Animated GIF for some presentation software...

I can't use the web browser control because it doesn't allow me to trigger the form_click events etc... and I don't want to use an image box, I want a Picture box...

I also don't want a commercial OCX... and would like to basically copy frames from an animated gif intoa  picture box
0
Comment
Question by:matthew1471
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11721551
Easy!

1. Place a WebBrowser control on your form
2. Place a PictureBox on your form. This will cover the scroll bar on your WebBrowser control
3. Pleace the following code in the form load event:

Private Sub Form_Load()

    Const SBAR_WIDTH = 17
    Const BORDER_WIDTH = 2
   
    Dim fname As String
    Dim w As Single
    Dim h As Single
    Dim l As Single
    Dim t As Single

    SetFormIcon Me
   
    ' Get the filename.
    fname = App.Path
    If Right$(fname, 1) <> "\" Then fname = fname & "\"
    fname = fname & "MyAnimatedGif.gif"
    'or
    fname = "C:\MyAnimatedGif.gif"

    With WebBrowser1
        .Navigate fname
        w = ScaleX(SBAR_WIDTH, vbPixels, ScaleMode)
        h = .Height - ScaleX(2 * BORDER_WIDTH, vbPixels, ScaleMode)
        l = .Left + WebBrowser1.Width - ScaleX(SBAR_WIDTH + BORDER_WIDTH, vbPixels, ScaleMode)
        t = .Top + ScaleY(BORDER_WIDTH, vbPixels, ScaleMode)
    End With
   
    With Picture1
        ' Cover the scroll bar.
        .BorderStyle = vbBSNone
        .BackColor = vbWindowBackground
        .Move l, t, w, h
        .ZOrder
    End With

End Sub
0
 
LVL 18

Accepted Solution

by:
JR2003 earned 150 total points
ID: 11721793
oops sorry I didn't see that you didn't want to use a WebBrowser control!
It is possible to do it without one but the code is a lot more detailed and not as stable and prone to flicker on large gifs.
email me if you want a copy.



0
 
LVL 18

Assisted Solution

by:Sethi
Sethi earned 100 total points
ID: 11722212
0
 
LVL 3

Author Comment

by:matthew1471
ID: 12024865
I managed to solve this problem myself, I created an OCX using the WebBrowser control..and found a site on how to kill the right click menu...

The Animated gifs sometimes display *very* poorly.. but that is actually down to Microsoft's fault.

I have given JR2003 the points because I am consious of the number of questions i've ended up solving myself, it's going to annoy people... and technically the solution was the WebBrowser control....

Have a nice weekend

If anyone wants the code I have, e-mail me
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 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