Working with IHTMLDocument2...

I am working on a project that requires us to have a web browser embedded in our windows application.  This is relatively easy to do if you are using the load to bring in an external URL or a URL pointing to temp file.  But I wanted to be able to use an XSLT stylesheet and transform some xml into HTML, without saving to a temp file.  I found you are able to use the GetBody and change the innerHTML of that element, but you can't change anything above body.   (I want to change the inner/outer HTML of the Document.)

I started parsing the html to be displayed using regex and pulling out the script and style elements and putting them into the body.  (IE usually allows for this kind of thing)  But I am not getting it to work exactly the way I want.

I also tried writing the style using CreateStyleSheet() but it thinks the css I am giving it is a URL instead of code.

If anyone knows of a way to implement write() on the document or an easier way of doing this, please let me know!!

p.s.  We are not using the ActiveX control.  We are wrapping the COM object in order to get around a bug with the ActiveX control displaying in docking controls. 

Recent Posts

Tag Cloud

3 Comments

  • at one point I did a test with a .net warapper that seemed to work well...



    I don't have the original link handy but it was a .net control used by the SharpDevelop folks.



    can you host a private copy of the asp.net server in the app?



    I have heard that you can use that to generate pages ... the trick is to hook the web browser to the asp.net with streams or pipes to avoid writing to disk.



  • the stuff I saw was about 1 to 1.5 years back.



    it was a dll made by someone else that used the MS IE com bits and if you want to it you could do all kinds of stuff....



    they may have changed that part as I know they used to use a gui lib. that they dumped.



    I'll see If i can find the dll / net thing...

  • This only works if you are using the activex control.



    Also, createStyleSheet works fine if you give it a file, but I was trying to give it the actual style text.



    Thanks though!



Comments have been disabled for this content.