How to get the url for which the downloadBegin () event fires?

I am trying to create my own web browser based on a WPF web browser control. I implemented the IWebBrowser2 com interface and implemented handlers for the events Navigating() , NavigatedTo() and LoadCompleted() . But these event callbacks are fired only once for the top-level page. Now suppose the page has java script, css and image files; The browser downloads individual HTTP requests to download these files. We would like to capture individual HTTP request events. For example, if the structure of the HTML page

 <html> <body> <img src="img1.bmp"/> <imp src="img2.bmp"/> </body> </html> 

I would like to record separate boot times for img1.bmp and img2.bmp. Can someone suggest you a way to achieve this?

Meanwhile, I found that for this request for an image, etc. the downloadbegin () DWebBrowserEvents_Event , but I canโ€™t get the URL from which it is downloaded, because the handler takes the value void as a parameter.

So, is there a way to get the url because there is an event that is downloadComplete that fires when the download is complete. So I can do it.

But I have to solve the specified image rendering time. I am stuck badly. Please help me....

+6
c # wpf webbrowser-control
source share
1 answer

I do not have deep knowledge about these classes, but I read a little. in mdsn they talk about the downloadbegin () event: http://msdn.microsoft.com/en-us/library/cc136556(v=vs.85).aspx

This event will be fired shortly after the DWebBrowserEvents :: BeforeNavigate event or the DWebBrowserEvents2 :: BeforeNavigate2 event if navigation is not canceled. Any animation or busy indication that the container should display must be connected to this event.

and when I checked BeforeNavigate, I saw that it has a url in its parameters, I found this (not msdn, but its only logical that it has a url) http://blog.yezhucn.com/progie/222647_beforenavigate. htm

void BeforeNavigate (
IDispatch * pDisp, VARIANT * & url, VARIANT * & Flags, VARIANT * & TargetFrameName, VARIANT * & PostData, VARIANT * & Headers, VARIANT_BOOL * & Cancel);

therefore, if you will always have the BeforeNavigate event, you can use its url and check the next download completion event associated with the DownloadBegin event. I assume that for each download it fires the BeforeNavigate event, but I donโ€™t know, because I canโ€™t try (no code to check), but I hope it helps.

0
source share

All Articles