WebBrowser Control - intercept requests [modified]
-
Hi all I've searched and searched but I can't find a method that will enable me to intercept requests from a WebBrowser control and then provide my own, programmatically generated responses. Currently, my application uses the control to provide 90% of the UI by loading HTML, CSS and Javascript from disc using the "file" protocol. The scripts then call my app's dispatch interface to make things happen. What I would like to be able to do is effectively serve these files without coding my own HTTP server. I'm hoping there's a point at which I can intercept the WebBrowser's request and then write my own response back to it. This response will usual consist of the contents of a file extracted from an archive or from the app's resources. I would also like to be able to spot requests for images (by parsing the URL) so that I can render SVG graphics to a file as a PNG (or similar) and stream that file back to the browser. So, is there some interface I can implement and supply to the browser in order to achieve the above? As I said, I'd like to avoid writing my own HTTP server or Asynchronous Pluggable Protocol handler. Thanks in advance Simon
modified on Friday, January 30, 2009 10:56 AM (typo)
-
Hi all I've searched and searched but I can't find a method that will enable me to intercept requests from a WebBrowser control and then provide my own, programmatically generated responses. Currently, my application uses the control to provide 90% of the UI by loading HTML, CSS and Javascript from disc using the "file" protocol. The scripts then call my app's dispatch interface to make things happen. What I would like to be able to do is effectively serve these files without coding my own HTTP server. I'm hoping there's a point at which I can intercept the WebBrowser's request and then write my own response back to it. This response will usual consist of the contents of a file extracted from an archive or from the app's resources. I would also like to be able to spot requests for images (by parsing the URL) so that I can render SVG graphics to a file as a PNG (or similar) and stream that file back to the browser. So, is there some interface I can implement and supply to the browser in order to achieve the above? As I said, I'd like to avoid writing my own HTTP server or Asynchronous Pluggable Protocol handler. Thanks in advance Simon
modified on Friday, January 30, 2009 10:56 AM (typo)
Well, in case anyone stumbles across this post, I thought I'd let you know how I solved my problem (well, this one anyway)... Turns out a pluggable protocol is the solution. The basics are easy to write and, critically, they can be registered on a per-process basis. I invented my own URL scheme, implemented an APP for it, registered my APP class factory using CoInternetGetSession and IInternetSession::RegisterNameSpace and away I went. The UI is now "served" via my own URL scheme by my own APP on a per-process basis.