如何在PB中调用 Microsoft WEB 浏览器 控件

2026年09月27日 13:18
有2个网友回答
网友(1):

PB中使用Microsoft Web Browser控件步骤:
  
  在pb的某窗口中加入OLE对象,选择Insert control(插入控件),然后选中"Microsoft WEB 浏览器",(随系统而定的版本),就可以在这个窗口直接使用IE浏览器控件了。
  
  常用函数:(对这个ole控件取名叫ole_web)
  
  ole_web.object.navigate(string ls_url) file://浏览某url,
  
  譬如:ole_web.object.navigate('http://sunny.livecq.com) 就是浏览 http://www.techtarget.com.cn 页面,当然支持本地文件,也支持本地图片文件的浏览,如jpeg,jpg,gif,png等等,如果是不支持的文件,则直接弹出选择打开文件对话框,和ie一模一样。
  
  ole_web.object.goback() file://回退(如果没有内容可退,则会弹出错误,可以屏蔽该错误)
  
  ole_web.object.goforward() file://前进,同上
  
  常用事件:
  
  documentcomplete : url请求的页面完成;
  
  downloadcomplete:url中请求的下载完成;
  
  常用属性:
  
  ole_web.object.width :pixel高度,需要转换为pbunit高度才可以调整
  
  ole_web.object.height:同上
  
  ole_web.object.offline:离线方式,true,false两者之一
  
  你甚至可以用pb写出一个和ie类似的界面用来进行浏览网页或图片。
  
  Integer result
  
  oleobject objExplorer,ieDoc
  
  objExplorer = CREATE oleobject
  
  result = objExplorer.ConnectToNewObject( "InternetExplorer.Application")
  
  IF result = 0 THEN
  
  objExplorer.Navigate("about:blank")
  
  ieDoc = objExplorer.document
  
  objExplorer.ToolBar = 0
  
  objExplorer.StatusBar = 0
  
  objExplorer.Width = 300
  
  objExplorer.Height = 150
  
  objExplorer.Left = 0
  
  objExplorer.Top = 0
  
  objExplorer.Visible = 1
  
  END IF
  
  //这个可以执行JS
  
  oleobject WshShell
  
  WshShell = create oleobject
  
  WshShell.connecttonewobject( "WScript.Shell")
  
  integer li_Return
  
  li_Return = WshShell.Run("cscript E:\validate.js", 1, true)
  
  messagebox("",li_return)
  
  WshShell.DisconnectObject ( )
  
  destroy WshShell
  
  OLE嵌入浏览器,如何调用其载入网页中的函数
  
  比如网页中有这么个函数:
  
  PB中调用:
  
  ole_1.object.document.parentWindow.showmessage("吞硬币的小猪");

网友(2):

你好
根据你的描述,建议参考下面经验教程
http://www.baidu.com/link?url=vrjqvIc7Pi0LQJtkS-eUiD2hejm9-IVBC56qPfqYzFyKuoYRBYSs70zaiMjSS-YKw0n6KMBZ406rjVG1LTx-P1x98J-6ej-qaKBSC-XNKWu
你的采纳是我前进的动力,还有不懂的地方,请继续“追问”。
如你还有别的问题,可另外向我求助;答题不易,互相理解,互相帮助。