views:

95

answers:

2

For one of our desktop applications we use a HTML-based interface, loaded from local files into a WebBrowser control.

This works fine, but now we want to load the files from a different source, and are trying to stream them in using IPersistStreamInit (like this example on MSDN). It seems to work OK, except for the referenced javascript .js files (JQuery et al). It tries to load those from the "about:" location resulting in errors.

What I would really like is to get a callback event whenever additional files are streamed, and substitute the right data. That might be asking for a bit too much though, so suggestions for workarounds are welcome!

+2  A: 

You could use a lightweight custom protocol handler using an Asynchronous Pluggable Protocol, which would give a callback for files.

I have some demo code at http://www.jasontpenny.com/blog/2010/03/23/custom-protocol-handler-in-delphi/

jasonpenny
+2  A: 

Call CreateURLMoniker() to obtain an IMoniker interface, load your HTML data into it via its Load() method (which takes an IStream interface as input), and then you can use the browser's IPersistMoniker interface instead of its IPersistStreamInit interface to process the data. The URL you pass to CreateURLMoniker() will be used as the base URL.

Remy Lebeau - TeamB
I have now created a custom IMoniker implemementation, that loads my own data in the BindToStorage() method. Using IPersistMoniker my content now gets loaded, and TWebBrowser looks for additional files (javascript, images, etc) at the GetDisplayName() URL. Which is nice, but doesn't quite solve my problem yet: I need to provide the data for those additional files myself. Unsure how to proceed.
Paul-Jan