Library code snippets

Display animated GIFs in VB

While the Picture ActiveX control offers a great way to display
graphics, it only shows the first image in an animated GIF. To
display a fully animated GIF, without rebuilding the entire graphic
frame by frame, you can use the WebBrowser control (just keep in
mind that this control isn't available to machines without IE 3.0
or greater).  To do so, select the Microsoft Internet Controls
component. When you do, the WebBrowser control appears on Visual
Basic's toolbar. Drop the control onto a form, then in the form's
Load() event place the following code:

WebBrowser1.Navigate "C:Internetanim.gif"

Where the filespec points to a valid animated GIF path or URL. When
you run the program, Visual Basic displays the GIF.

Unfortunately, the WebBrowser also displays a right-hand scroll
bar--probably not what you want for a decorative image. Believe it
or not, you can turn this scrollbar off just like you would normally
via HTML, as in:

WebBrowser1.Navigate "about:<html><body scroll='no'><img
src='D:Internetanim.gif'></img></body></html>"


Now when you run the form, Visual Basic displays the image sans
scrollbar.

Comments

  1. 07 Feb 2005 at 13:09

    _ Margins set to 0
    _ Pic loaded from Application path


    WebBrowser1.Navigate "about:<html><body scroll='no' leftmargin='0' rightmargin='0' topmargin='0' bottommargin='0'><img src='" & App.Path & "\MyPic.gif'></img></body></html>"


    Edit : I didn't see comments were extracted from Forum posts and App.Path was proposed yet ...

  2. 12 Dec 2004 at 20:30

    I have this same problem, i have been searching for months.


    Can sum one who knows please respond or contact me.


    I dont like how when you have a webbrowser, it has a border around the edges.
    I dont know how to disable the border so its invisible.


    Thanks.


    Edit: I just noticed this is a old topic... hmmm i hope you still read this.

  3. 27 Nov 2004 at 19:00

    great code and tutorial.  but the html is a little off.  this should fix it.
    WebBrowser1.Navigate "about:<html><body scroll='no'><img src='c:\image.gif'></img></body></html>"

  4. 04 Jul 2002 at 02:54

    I have try this, but I have the problem with the border.
    How can I use the webbrowser control (Microsoft Internet Controls) without border (make hidden)?

  5. 04 Jul 2002 at 02:50

    I have try this, but I have the problem with the border.
    How can I use the webbrowser control (Microsoft Internet Controls) without border ?

  6. 04 Jul 2002 at 02:15

    try this, use app.path to specify your app working directory or just write complete path to make it sure,you have access the right directory

  7. 18 May 2002 at 01:32

    Hello,
    So if you write
    WebBrowser1.Navigate "C:Internetanim.gif"
    It works, but I couldn't find any syntax for putting it in the same directory as the pgm itself :


    WebBrowser1.Navigate "Internetanim.gif" wont work
    WebBrowser1.Navigate "\Internetanim.gif" wont work
    WebBrowser1.Navigate ".\Internetanim.gif" wont work
    WebBrowser1.Navigate "./Internetanim.gif" wont work


    and so on...
    Any idea ?
    Froggy Jacques







  8. 01 Jan 1999 at 00:00

    This thread is for discussions of Display animated GIFs in VB.

Leave a comment

Sign in or Join us (it's free).