首先,建立一个网页:
const
{ Was used sample from }
{ https://developers.google.com/maps/documentation/javascript/examples/directions-panel }
cRoute =
''
+ ''
+ ' '
+ ''
+ ''
+ 'setPanel()'
+ ''
+ ''
+ '
+ '
+ ' '
+ ' '
+ '
'
+ ' Start:'
+ ' '
+ ' End:'
+ ' '
+ '
'
+ ''
+ ''
+ ' '
+ ''
然后,用一个TWebBrowser调入:
WebBrowser1.LoadFromStrings(cRoute, '')
再声明两个常量:
cChicagoWinona =
'document.getElementByIdx_x(''start'').value = "chicago, il"'
+ 'document.getElementByIdx_x(''end'').value = "winona, az"'
+ 'calcRoute()'
cStLouisGallupNM =
'document.getElementByIdx_x(''start'').value = "st louis, mo"'
+ 'document.getElementByIdx_x(''end'').value = "gallup, nm"'
+ 'calcRoute()'
用两个按钮调用:
procedure TForm1.Button1Click(Sender: TObject)
begin
WebBrowser1.EvaluateJavaScript(cChicagoWinona)
end
procedure TForm1.Button2Click(Sender: TObject)
begin
WebBrowser1.EvaluateJavaScript(cStLouisGallupNM)
end
wb1: TWebBrowser;wb1.Navigate(URL)
在wb1DocumentComplete事件中
var
i: IHTMLDocument2//需要uses MSHTML
i := wb1.Document as IHTMLDocument2
通过IHTMLDocument2的接口即可得到任何你想要的东西。
1、在word插件的onConnection事件里设置插件对象的object属性,我是用delphi写的procedure TWordTest.OnConnection(const Application: IDispatchConnectMode: ext_ConnectModeconst AddInInst: IDispatch
var custom: PSafeArray)
begin
COMAddIn(AddInInst).Object_ := Self
end
2、在js里如下调用
var addin = wdApp.COMAddIns.Item("插件名称" ) //插件名称是在word中注册时用到的名称
if(addin != null){
addin.Object.Test()
}
另外,告诉大家一个在delphi里调试word插件的方法
在OnConnection事件里弹出一个提示框,然后使用delphi的attach to process功能,在进程列表中选word,就可以调试了