Skip to content Skip to sidebar Skip to footer

C++, Win32 Api: How To Create An Html Rendering Window So That Your Application Would Get Callbacks From JS Calls?

What I need is simple: we have a console app project. We want to have such a function that would open a simple window with nothing but html (default system based) html + js renderi

Solution 1:

  1. CoCreate the MSHTML com object for HTML Documents:

    CComPtr spDoc; HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_IHTMLDocument2, (void**)&spDoc);

  2. Do something like this to read your HTML string and make the document render it.

  3. Depending on what you need in terms of callbacks, you can use the COM DOM Interfaces to traverse the tree, and then sink the appropriate DispInterfaces to get events on the elements you're interested in. I would recommend this.

  4. If what I suggest in #3 isn't good enough for you (and I'd like to hear why) then you can implement your own ActiveX control and have script on your page call methods on it as suggested by raj.


Solution 2:

Brushing aside any security / cross browser/platforms concerns you can use implement an ActiveX object in your C++ that you can invoked from javascript.

http://msdn.microsoft.com/en-us/library/7sw4ddf8(v=vs.94).aspx


Solution 3:

The host for the WebBrowser control can provide an object that will be accessible to scripts via the external object.

See http://msdn.microsoft.com/en-us/library/aa770041.aspx#GetExternal


Post a Comment for "C++, Win32 Api: How To Create An Html Rendering Window So That Your Application Would Get Callbacks From JS Calls?"