The Web Browser control displays animated gifs quite nicely. Size the control on a form and...
[tt]
WebBrowser1.Navigate App.Path & "\MyAnimated.gif"
[/tt]
How simple can you get?
That was the method I was thinking of using but in the end it is no good, in my opinion. The WebBrowser control always appears with a border, and always puts in a vertical scroll bar (at least it does here, even though the documentation claims otherwise). Which is a pain.
We just need an alternative to the WebBrowser control that doesn't suffer from these drawbacks...and the DHTML Edit Control for IE5 is ideal.
Add the above to your project as a component. Drop a DHTMLSafe control onto your form, and add a command button. Then copy and paste the following code:
Option Explicit
Private Sub Command1_Click()
LoadDHTMLImage "<full_path_to_your_gif_file>"
End Sub
Public Function LoadDHTMLImage(strFile As String) As Boolean
Dim myHTML As String
Dim picDummy As StdPicture
Dim strImageLoad As String
Set picDummy = LoadPicture(strFile)
DHTMLSafe1.Width = ScaleX(picDummy.Width, 6, 1) / 100 ' scale from STDPicture's HiMetric to Twips
DHTMLSafe1.Height = ScaleY(picDummy.Height, 6, 1) / 100 ' scale from STDPicture's HiMetric to Twips
' Note: we are forming REALLY bad HTML here, but it does the job...
strImageLoad = "<img src='file:///" + strFile + "'>"
myHTML = "<body topmargin='0' leftmargin='0'>"
myHTML = myHTML + strImageLoad
myHTML = myHTML + "</body>"
DHTMLSafe1.NewDocument
DHTMLSafe1.DocumentHTML = myHTML
End Function
The Web Browser scroll bar and border really aren't a problem if you don't mind adding an extra control.
Place a borderless, captionless frame on the form, size it until it is only as large as the GIF. Resize the Web Browser control until it is about 25% larger than the GIF. Cut the Web Browser and paste it on the frame. Drag it up and to the left a bit and run the project.
The borders and scroll bars will disappear.
Not nearly as functional as Strongm's solution but it might be a bit easier to use.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.