Solved

Animated GIF in Picture Box

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

734 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