如何使WebBrowser中的内容滚动?(100分)

  • 主题发起人 主题发起人 lxggc
  • 开始时间 开始时间
L

lxggc

Unregistered / Unconfirmed
GUEST, unregistred user!
对于一般的Memo或ListBox可以通过向他们传递 WM_KEY 或 WM_VSCROLL 等消息可以<br>让他们滚动,但WebBrowser对这些消息没有反映,如何使WebBrowser由程序控制<br>使其内容平滑滚动?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=715435<br><br>WebBrowser的真正相应消息的句柄是'Internet Explorer_Server',<br>var<br>&nbsp; IE : TWebBrowser;<br>begin<br>&nbsp; IEHandle := findWindowEx(IE.Handle, 0, 'Shell DocObject View', nil);<br>&nbsp; IEHandle := findWindowEx(IEHandle, 0, 'Internet Explorer_Server', nil);<br>&nbsp; SendMessage(IEHandle, WM_VSCROLL, ... ...<br>&nbsp; ... ...<br>end;<br>
 
uses<br>&nbsp; MSHTML;<br><br>procedure WebBScroll(WB: TWebBrowser; X, Y: Integer);<br>begin<br>&nbsp; ((WB.Document as IHTMLDocument2).parentWindow as IHTMLWindow2).scroll(X ,Y);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; WebBScroll(WebBrowser1, 10, 400);<br>end;
 
谢谢 oopsWare 给出的回复,经测试完全可行,DragonPC_??? 给出的答案运行时没有任何响应,不知道是不是我写的程序有问题,<br>总之,感谢两位的回答。
 
请使用JAVAScript,Code 如下:<br>strText:=StringReplace('滚动内容',#13#10,'''+'+#13#10+'''&lt;br&gt;',[rfReplaceAll]);<br>'&lt;HTML&gt;'+ #13#10 +<br>'&lt;HEAD&gt;'+ #13#10 +<br>'&lt;TITLE&gt;&lt;/TITLE&gt;'+ #13#10 +<br>'&lt;meta http-equiv="Content-Type" content="text/html; charset=GB2312"&gt;'+ #13#10 +<br>'&lt;style type="text/css"&gt;'+ #13#10 +<br>'&lt;!--'+ #13#10 +<br>'.fontsmall { &nbsp;font-size: 12px; text-decoration: none; line-height: 18px}'+ #13#10 +<br>'.fontbig { &nbsp;font-size: 14.8px; text-decoration: none; line-height: 20px}'+ #13#10 +<br>'a:hover { &nbsp;color: #F77C02; text-decoration: underline}'+ #13#10 +<br>'a:link { &nbsp;text-decoration: none}'+ #13#10 +<br>'a:visited { &nbsp;text-decoration: none}'+ #13#10 +<br>'body { &nbsp;font-size: 12px; line-height: 16px}'+ #13#10 +<br>'--&gt;'+ #13#10 +<br>'&lt;/style&gt;'+ #13#10 +<br>'&lt;/HEAD&gt;'+ #13#10 +<br>'&lt;body bgcolor="#000000" leftmargin="0" topmargin="0"&gt;'+ #13#10 +<br>'&lt;table width="100%" height="100%"&gt;'+ #13#10 +<br>' &nbsp;&lt;tr&gt;'+ #13#10 +<br>' &nbsp; &nbsp;&lt;td class="unnamed1" width="100%" rowspan="1" valign="top" height="100%"&gt;'+ #13#10 +<br>' &nbsp; &nbsp; &nbsp;&lt;p class="fontsmall"&gt;'+ #13#10 +<br>' &nbsp; &nbsp; &nbsp; &nbsp;&lt;script language="JavaScript1.2"&gt;'+ #13#10 +<br>'var marqueewidth=256'+ #13#10 +<br>'var marqueeheight=128'+ #13#10 +<br>'var speed=1'+ #13#10 +<br>'var marqueecontents=''&lt;font color="#FF0000"&gt;'+[red]strText[/red]+'&lt;/font&gt;'''+ #13#10 +<br>'if (document.all)'+ #13#10 +<br>'document.write(''&lt;marquee direction="'+方向(up,down,left,right)+'" scrollAmount=''+speed+'' style="width:''+marqueewidth+'';height:''+marqueeheight+''"&gt;''+marqueecontents+''&lt;/marquee&gt;'')'+ #13#10 +<br>'function regenerate(){'+ #13#10 +<br>'window.location.reload()'+ #13#10 +<br>'}'+ #13#10 +<br>'function regenerate2(){'+ #13#10 +<br>'if (document.layers){'+ #13#10 +<br>'setTimeout("window.onresize=regenerate",450)'+ #13#10 +<br>'intializemarquee()'+ #13#10 +<br>'}'+ #13#10 +<br>'}'+ #13#10 +<br>'function intializemarquee(){'+ #13#10 +<br>'document.cmarquee01.document.cmarquee02.document.write(marqueecontents)'+ #13#10 +<br>'document.cmarquee01.document.cmarquee02.document.close()'+ #13#10 +<br>'thelength=document.cmarquee01.document.cmarquee02.document.height'+ #13#10 +<br>'scrollit()'+ #13#10 +<br>'}'+ #13#10 +<br>'function scrollit(){'+ #13#10 +<br>'if (document.cmarquee01.document.cmarquee02.top&gt;=thelength*(-1)){'+ #13#10 +<br>'document.cmarquee01.document.cmarquee02.top-=speed'+ #13#10 +<br>'setTimeout("scrollit()",100)'+ #13#10 +<br>'}'+ #13#10 +<br>'else{'+ #13#10 +<br>'document.cmarquee01.document.cmarquee02.top=marqueeheight'+ #13#10 +<br>'scrollit()'+ #13#10 +<br>'}'+ #13#10 +<br>'}'+ #13#10 +<br>'window.onload=regenerate2'+ #13#10 +<br>'&lt;/script&gt;'+ #13#10 +<br>' &nbsp; &nbsp; &nbsp; &nbsp;&lt;ilayer width="&amp;amp;{marqueewidth};" height="&amp;amp;{marqueeheight};" name="cmarquee01"&gt;'+ #13#10 +<br>' &nbsp; &nbsp; &nbsp; &nbsp;&lt;layer name="cmarquee02" width="&amp;amp;{marqueewidth};" height="&amp;amp;{marqueeheight};"&gt;&lt;/layer&gt;'+ #13#10 +<br>' &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ilayer&gt;'+ #13#10 +<br>' &nbsp; &nbsp; &nbsp; &nbsp;&lt;/p&gt;'+ #13#10 +<br>' &nbsp; &nbsp;&lt;/td&gt;'+ #13#10 +<br>' &nbsp;&lt;/tr&gt;'+ #13#10 +<br>'&lt;/table&gt;'+ #13#10 +<br>'&lt;/BODY&gt;'+ #13#10 +<br>'&lt;/HTML&gt;';
 
接受答案了.
 
为什么我用oopsWare 的方法显示“interface notsupported”
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部