I'm building an IE addon 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 anyone help me with that?
Thanks,
Omri
You need to relay calls to IShellUIHelper and IShellUIHelper2 members to the shell UI helper object in your external object.
Javascript calls the members of your external object via IDispatch, so you need to make sure you have implemented Invoke and GetIDsOfNames correctly. In terms of managed code programming, that means you need to have the right method signature in your class and add the right [DispId] to your methods.
There is a declaration of IShellUIHelper in the csexwb2 project that you can use as reference.