tags:

views:

587

answers:

1

I would like to migrate my app to using MHTML for the GUI since it would be much easier to experiment with layouts without rewriting the C++ every time.

Is there a tutorial? What I found is unfortunately not what I need, which is:

  • Feed it HTML from memory
  • Receive events such as onclick, etc., back in my C++ code
  • Manipulate it through the DOM, e.g., set the innerHtml of a particular element

Many thanks in advance.

+2  A: 

The ugly part is going to be receiving the events. Directly coding to the COM interface of MSHTML in C++ to attach logic to an HTML GUI is going to be pretty ugly if you do it "raw". You'll probably want a thin-ish layer of library code to sit between your application logic and HSHTML, to hide the COM-related plumming.

Ultimately this is a reinvention of things like Firefox's XUL - see http://en.wikipedia.org/wiki/XUL. You may find that more ready for use in this way. You'd be hosting the Gecko engine instead of MSHTML.

Or alternatively you could use WPF, which is again very similar. Given that you're on Windows (as you're happy with a dependency on MSHTML), you could write the GUI stuff in C# and bind it to the C++ code by exposing that with C++/CLI.

Daniel Earwicker
+1 for Gecko. XUL and Gecko aren't exactly identical, but that's a detail.
MSalters