|
Omri Suissa
Guest
|
I'm not sure this is the right place to post my question but...
I'm building an IE addon (with addin express :)) and i want to "be" the external object. therefore i use the SetUIHandler to set my class as the UIHandler.
I'm implementing IDocHostUIHandler (referencing to Microsoft Internet Controls (COM Object)) and in GetExternal i return my class:
public void GetExternal(out object ppDispatch)
{
ppDispatch = this;
}
This works great. any other option is not interesting me so i need to return E_NOTIMPL.
for example:
public void TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID)
{
Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL);
}
works great, but i need also to implement IShellUIHelper (IE expect it from the UIHandler).
and then when i implement add to favorites:
public void AddFavorite(string URL, ref object Title)
{
Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL);
}
it don't work (the js got and error).
when i tried to do the same in C++ and return the E_NOTIMPL as return value everything works great:
STDMETHODIMP CMyClass::AddToFavoritesBar(BSTR URL, BSTR Title, VARIANT *Type)
{
return E_NOTIMPL;
}
i also tried to replace the Marshal.ThrowExceptionForHR((int)WinAPI.HRESULT.E_NOTIMPL); with throw new COMException("", (int)WinAPI.HRESULT.E_NOTIMPL); and it still don't work.
can you help me with that?
Thanks,
Omri |
|
Posted 18 Oct, 2011 08:21:07
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Omri,
Can you please provide the code of the add-on written in C++? I will test it.
public void GetExternal(out object ppDispatch)
{
ppDispatch = this;
}
This is the incorrect code. You should return the loader proxy object and it is not available in the .NET code. |
|
Posted 18 Oct, 2011 10:37:31
|
|
Top
|
|
Omri Suissa
Guest
|
In C++ everything is working great:
...
STDMETHODIMP CMyClass::OnDocumentComplete(IDispatch *pDisp, VARIANT *URL, BOOL delaySetSiteIsReady)
{
if (mMainBrowser.IsEqualObject(pDisp))
{
CComPtr<IDispatch> spDisp;
mMainBrowser->get_Document(&spDisp);
if (spDisp)
{
CComQIPtr<IHTMLDocument2> spHTMLDoc(spDisp);
if (spHTMLDoc)
{
// Request default handler from MSHTML client site
CComQIPtr<IOleObject> spOleObject(spDisp);
if (spOleObject)
{
CComPtr<IOleClientSite> spClientSite;
spOleObject->GetClientSite(&spClientSite);
if (spClientSite)
{
X if (m_spDefaultDocHostUIHandler)
X {
X m_spDefaultDocHostUIHandler.Release();
X m_spDefaultOleCommandTarget.Release();
X }
X Save pointer for later use
X spClientSite->QueryInterface(IID_IDocHostUIHandler, (LPVOID*)&m_spDefaultDocHostUIHandler);
X spClientSite->QueryInterface(IID_IOleCommandTarget, (LPVOID*)&m_spDefaultOleCommandTarget);
}
}
// Set this class to be the IDocHostUIHandler
CComQIPtr<ICustomDoc> spCustomDoc(spDisp);
if (spCustomDoc)
{
spCustomDoc->SetUIHandler(this);
}
}
}
}
}
all methods look like this:
STDMETHODIMP CMyClass::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved,IDispatch *pdispReserved)
{
HRESULT hr = E_NOTIMPL;
if (m_spDefaultDocHostUIHandler)
{
hr = m_spDefaultDocHostUIHandler->ShowContextMenu(dwID, ppt, pcmdtReserved, pdispReserved);
}
return hr;
}
the external override:
STDMETHODIMP CMyClass::GetExternal(IDispatch **ppDispatch)
{
// Assumes you inherit from IDispatch
*ppDispatch = (IDispatch*)this;
(*ppDispatch)->AddRef();
return S_OK;
} |
|
Posted 18 Oct, 2011 11:00:08
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
I just wanted to make sure that this is an add-on and not an application that hosts the WebBrowser ActiveX control. |
|
Posted 18 Oct, 2011 11:38:08
|
|
Top
|
|
Omri Suissa
Guest
|
|
Posted 18 Oct, 2011 11:40:06
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
If you send me the source code (without any specific functionality), I will try to implement it in ADX loader (the loader is written in C++). |
|
Posted 18 Oct, 2011 11:45:58
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Omri,
I will investigate a possibility for implementing the IDocHostUIHandler interface in the loader.
Most likely I will add the implementation to the next build of the product. |
|
Posted 19 Oct, 2011 04:16:24
|
|
Top
|
|
Omri Suissa
Guest
|
|
Posted 19 Oct, 2011 06:12:30
|
|
Top
|
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
|
Posted 19 Oct, 2011 07:03:10
|
|
Top
|
|