E
eaglepsm
Unregistered / Unconfirmed
GUEST, unregistred user!
我在用Delphi写一个浏览器,需要调用IDM_开头的一些接口(比如IDM_KEEPSELECTION),我用WebBrowser1.ExecWB(IDM_KEEPSELECTION,OLECMDEXECOPT_DODEFAULT)始终出错:“试图吊销一个未注册的拖放目标”,用WebBrowser1.QueryStatusWB(IDM_KEEPSELECTION)发现并不支持该接口,我想可能是ExecWB本来就不支持以IDM_开头的接口,查了一下全文检索,发现C++Builder的ExecWbEx函数可以,但Delphi的WebBrowser没有ExecWbEx函数,下面是函数的C++代码,各位能不能帮我翻译成Delphi,谢谢
void TForm1::ExecWBEx(int cmdID,TVariant *pvaIn,TVariant *pvaOut,int nCmdExecOpt)
{
IDispatch * WebDocument = static_cast<IDispatch *>(CppWebBrowser->Document);
IHTMLDocument2 *HTMLDocument = static_cast<IHTMLDocument2 *>(WebDocument);
if(HTMLDocument)
{
IOleCommandTarget *pCmd;
HRESULT hr=HTMLDocument->QueryInterface(IID_IOleCommandTarget,(void **)(&pCmd));
if(SUCCEEDED(hr))
{
pCmd->Exec(&CGID_MSHTML,cmdID,nCmdExecOpt,pvaIn,pvaOut);
}
}
}
void TForm1::ExecWBEx(int cmdID,TVariant *pvaIn,TVariant *pvaOut,int nCmdExecOpt)
{
IDispatch * WebDocument = static_cast<IDispatch *>(CppWebBrowser->Document);
IHTMLDocument2 *HTMLDocument = static_cast<IHTMLDocument2 *>(WebDocument);
if(HTMLDocument)
{
IOleCommandTarget *pCmd;
HRESULT hr=HTMLDocument->QueryInterface(IID_IOleCommandTarget,(void **)(&pCmd));
if(SUCCEEDED(hr))
{
pCmd->Exec(&CGID_MSHTML,cmdID,nCmdExecOpt,pvaIn,pvaOut);
}
}
}