Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Embed animation gif in VB

Status
Not open for further replies.

skyplayer

Programmer
May 28, 2002
13
HK
I would like to embed an animation gif in a picture box or image box in VB6, but the gif picture just a static picture in the run time and design time.
Thus is it possible to embed an animation gif in a VB program?Thx a lot!
 
have a look at thread702-86366 I have tried this all once before.

Good luck their are some good outcomes and bad outcomes to this.

Zero Anarchy
 
Sadly neither the VB Picturebox or Image control support animated gifs. However, browsers do! So consider dropping a Webbrowser DHTML Edit control onto your form. I happen to prefer the DHTML Edit control, so here is an example: pop a DHTML Edit control onto a form (you'll need to have added it a a component, set its Appearance property to 0 (flat), and Scrollbars property to False (this is one of the reasons why I prefer the DHTML control to the Webbrowser; it is easier to get rid of scrollbars...), then add this function to your project:
[tt]
Private Function DHTMLLoadPicture(strPicFile As String, Optional StretchToFit As Boolean = False) As Picture
Dim tmpPic As Picture
Dim OldScale As Long

Set tmpPic = LoadPicture(strPicFile)

OldScale = Form1.ScaleMode
If StretchToFit Then
Form1.ScaleMode = vbMillimeters
DHTMLEdit1.Width = tmpPic.Width / 100 ' Picture width and height are returned in HiMetric units
DHTMLEdit1.Height = tmpPic.Height / 100 ' so convert to millimeters

' Webbrowser control version
' WebBrowser1.Width = tmpPic.Width / 100
' WebBrowser1.Height = tmpPic.Height / 100
End If
DHTMLEdit1.DocumentHTML = &quot;<body topmargin='0' leftmargin='0'><p><img border='0' src='&quot; + strPicFile + &quot;'></p></body>&quot;

' Webbrowser control version
' WebBrowser1.Navigate &quot;about:blank&quot;
' WebBrowser1.Document.write &quot;<html><head><style type='text/css'><!--body { overflow:hidden; }--></style></head><body topmargin='0' leftmargin='0'><p><img border='0' src='&quot; + strPicFile + &quot;'></p></body></html>&quot;

Form1.ScaleMode = OldScale
Set DHTMLLoadPicture = tmpPic
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top