Search code examples
activexwebbrowser-controlatl

How to access host's DOM from inside of ActiveX control?


I have an ActiveX control written using the ATL framework. This ActiveX control is hosted inside a Windows Sidebar gadget. I need to access the DOM of the host from inside of the ActiveX control. E.g. change some colors in the parent HTML code from inside the ActiveX.

Is this possible at all? If yes, how can I get IWebBrowser2 or IHTMLDocument2 or similar interface?


Solution

  • The HTML document is your OLE client site's container:

    INFO: Accessing the Object Model from Within an ActiveX Control

    I would create an event and write the DOM modifying code in a javascript event handler, in this way i do not have to recompile the ActiveX when the web page's structure changes.