|
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://www.techtarget.com.cn') 就是浏览 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("吞硬币的小猪"); 不过注意,JavaScript的函数是区分大小写的,而PB对大小写不敏感:),因此只有网页中函数名称是小写的时候,才能够在PB中调用。 | |
| 文章评论 | |||