Solved

Animated GIF in Picture Box

Posted on 2004-08-04
4
456 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Convert Excel Column Headers to Rows 8 81
VBA Check for Character 9 69
VBA color chart bars 12 65
Updates not working for MS Windows 7 12 122
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now