How to get the URL for which downloadBegin() event is fired?
I am attempting to create a custom web browser based on the WPF Web browser control. I have implemented the IWebBrowser2 com
interface and implemented the handlers for Navigating()
, NavigatedTo()
and LoadCompleted()
events.
But these event callbacks are fired only once for the top level page.
Now suppose a page has some java script , css and image files in it; the browser issues separate HTTP requests to download these files. We would like to capture the individual HTTP request events. For example, if th开发者_开发百科e structure of the HTML page is
<html>
<body>
<img src="img1.bmp"/>
<imp src="img2.bmp"/>
</body>
</html>
I would like to capture the individual download times for img1.bmp and img2.bmp. Could someone please suggest a way to achieve this?
Meanwhile I found that downloadbegin() event of DWebBrowserEvents_Event
is fired for these request for image etc, but I can't get the URL from which it is downloading, as the handler takes void as parameter.
So is there any way I can get the URL corresponding because there is event that is downloadComplete which is fired when download is complete. So by that I can accomplish that way.
But I have to solve the above image rendering time. I am stuck badly. Please help me....
i dont have deep knowledge about this classes but i did a little reading. in mdsn they say about the downloadbegin() event: http://msdn.microsoft.com/en-us/library/cc136556(v=vs.85).aspx
This event is fired shortly after the DWebBrowserEvents::BeforeNavigate event or the DWebBrowserEvents2::BeforeNavigate2 event, unless the navigation is canceled. Any animation or "busy" indication that the container must display should be connected to this event.
and when i checked the BeforeNavigate i saw that it has a url in its paramaters i found this (not msdn but its only logical that itll have 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 );
so if you will always have a BeforeNavigate event you can use its url and check the next download complete event thats connected to the DownloadBegin event. my guess is that for each download it makes a BeforeNavigate event but i wont know because i cant try (no code to check it on) but i hope itll help.
精彩评论