Solved

Animated GIF in Picture Box

Posted on 2004-08-04
4
461 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
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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