How to get the IHTMLElement pointer to an <object> tag that contains an activex control

I have an ActiveX control created by the FireBreath framework (http://firebreath.org). I need to get a link to the <object> tag on the page that hosts the C ++ plugin.

If I used NPAPI, I would use the constant NPNVPluginElementNPObject with NPN_GetValue.

to make sure I'm clearing up, I’ll say that the page has the following:

<object id = "testPlugin" type = "application / x-someplugin" width = "100%" height = "100%"> </object>

I want to get a link to the plugin as if I were using document.getElementById ("testPlugin"), with the exception of the C ++ code of the activex control that is inserted for this mimetype type.

Please note that passing id in the form of <param> is not a good option for me, but if there is a way to get the identifier inside the activex element that may work.

edit: I am considering using getElementsByTagName and trying to find it through the DOM, but it would be hard to tell the difference between two instances of the same plugin.

+4
source share
2 answers

Thanks to the FireBreath contributor from Japan, we finally got the solution.

The first thing is that the COM object should be registered as "Apartment", and not "Single" (in the registry). Otherwise this will not work; seems to be a bug in COM.

Then after calling SetClientSite you can do the following:

CComQIPtr<IOleControlSite> site(m_spClientSite); CComPtr<IDispatch> dispatch; site->GetExtendedControl(&dispatch); CComQIPtr<IHTMLElement2> htmlElement = dispatch; 

Hope this helps someone; It took me almost 2 years to find someone who could answer this for me.

The object in the htmlElement will be the <object> tag that wraps your plugin; therefore, if you request an interface for any of your interfaces, it should succeed, but in reality it cannot be literally your object, most likely it will be a wrapper for your object.

+2
source

In C #:

  public int SetSite(object site) { if (site != null) { var oleControl = (IOleControlSite)site; object oHtmlElement; oleControl.GetExtendedControl(out oHtmlElement); var htmlElement = (IHTMLElement2)oHtmlElement; ... } } 
0
source

All Articles