明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

怎么使用WebBrowser控件顯示GIF動(dòng)畫(huà)

[摘要]作者: playyuer  要有一定的網(wǎng)頁(yè)知識(shí)(HTML、JavaScript、CSS)注意細(xì)節(jié):沒(méi)有"滾動(dòng)條"和"鼠標(biāo)右鍵彈出的 IE 上下文菜單",&qu...
作者: playyuer  


要有一定的網(wǎng)頁(yè)知識(shí)(HTML、JavaScript、CSS)
注意細(xì)節(jié):
沒(méi)有"滾動(dòng)條"和"鼠標(biāo)右鍵彈出的 IE 上下文菜單",".HTM 源文件" ...
我寫(xiě)了一個(gè),效果還真不錯(cuò)!

注釋:Objects: Form1、Command1、CommonDialog1、WebBrowser1
Option Explicit
Private Sub Command1_Click()
CommonDialog1.ShowOpen
If VBA.Len(VBA.Trim(CommonDialog1.FileName)) > 0 Then
  Dim p As stdole.StdPicture
  Dim sPath As String
  sPath = VBA.Trim(VBA.Trim(CommonDialog1.FileName))
  Set p = VB.LoadPicture(sPath)
  WebBrowser1.Width = p.Width * 16 / 26
  WebBrowser1.Height = p.Height * 16 / 26
注釋:  WebBrowser1.Navigate "about:blank"
  WebBrowser1.Document.open
  WebBrowser1.Document.writeln "<HTML>"
  WebBrowser1.Document.writeln "<HEAD>"
  WebBrowser1.Document.writeln "<TITLE>"
  WebBrowser1.Document.writeln "</TITLE>"
  WebBrowser1.Document.writeln "</HEAD>"
  WebBrowser1.Document.writeln "<BODY scroll=" & VBA.Chr(34) & "no" & VBA.Chr(34) & " oncontextmenu=self.event.returnValue=false>"
  WebBrowser1.Document.writeln "<div style=" & VBA.Chr(34) & "position:absolute; left: 0; top: 0" & VBA.Chr(34) & ">"
  WebBrowser1.Document.writeln "<IMG SRC=" & VBA.Chr(34) & sPath & VBA.Chr(34) & " BORDER=" & VBA.Chr(34) & "0" & VBA.Chr(34) & ">"
  WebBrowser1.Document.writeln "</div>"
  WebBrowser1.Document.writeln "</BODY>"
  WebBrowser1.Document.writeln "</HTML>"
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "&Open"
WebBrowser1.Navigate "about:blank"
WebBrowser1.Document.open
WebBrowser1.Document.writeln "<HTML>"
WebBrowser1.Document.writeln "<HEAD>"
WebBrowser1.Document.writeln "<TITLE>"
WebBrowser1.Document.writeln "</TITLE>"
WebBrowser1.Document.writeln "</HEAD>"
WebBrowser1.Document.writeln "<BODY scroll=" & VBA.Chr(34) & "no" & VBA.Chr(34) & " oncontextmenu=self.event.returnValue=false>"
WebBrowser1.Document.writeln "</BODY>"
WebBrowser1.Document.writeln "</HTML>"
WebBrowser1.Document.Close
End Sub