HOWTO: Determine When a Page Is Done Loading in WebBrowser CtrlLast reviewed: February 5, 1998Article ID: Q180366 |
The information in this article applies to:
SUMMARYThe Internet Explorer WebBrowser control fires the DocumentComplete event when it is finished downloading a Web page. You can create a event handler function in your application for this event. This article describes the steps to take in determining if a the WebBrowser control is finished downloading a Web page.
MORE INFORMATIONThe WebBrowser control fires the DocumentComplete event when its ReadyState property is changed to READYSTATE_COMPLETE. This indicates that the WebBrowser control has completed downloading the Web page. Here are some important points regarding this event:
NOTE: These steps are done for you automatically if you add a handler for the DocumentComplete event using the Class Wizard that comes with Visual C++. The only code that you will have to add is what is given in the OnDocumentComplete function:
The WebBrowser control is hosting a frameset. Within one frame of the frameset, the user clicks on a link that opens a new page in the frame itself and keeps the rest of the frameset intact. The new page could contain multiple frames again. So, there will be multiple DocumentComplete notifications (one for each new frame). But, since the top-level frame has not changed, the final DocumentComplete would be that of the frame that has changed. If you are interested in checking for the final document complete in this scenario, you could do the following:
LPDISPATCH glpDisp = NULL; // global LPDISPATCH, can also // be of class scope // NavigateComplete2 event void CWebbrDlg::OnNavigateComplete2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL) { // Check if glpDisp is NULL. If NULL, that means it is // the top level NavigateComplete2. Save the LPDISPATCH if (!glpDisp) glpDisp = pDisp; } void CWebbrDlg::OnDocumentCompleteExplorer1(LPDISPATCH pDisp, VARIANT FAR* URL) { if (glpDisp && glpDisp == pDisp) { // if the LPDISPATCH are same, that means // it is the final DocumentComplete. Reset glpDisp TRACE("Document is done downloading"); glpDisp = NULL; } } REFERENCESInternet Client SDK Help (http://www.microsoft.com/msdn/sdk/inetsdk/help/); Search on: "Reusing the WebBrowser Control" in the "Internet Tools and Technologies" section.
|
Additional query words: DocumentComplete
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |