如何利用 WebBrowser 控件,显示 .GIF 动画?

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 playyuer 的 blog

要有一定的网页知识(html、javascript、css)
注意细节:
没有"滚动条"和"鼠标右键弹出的 ie 上下文菜单",".htm 源文件" ...
我写了一个,效果还真不错!

'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

本文关键:VB,Gif,HTML,WebBrowser
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top