A supplement to the webbrowser container series using C ++ SDK. About gethtmldocumentx ()

Source: Internet
Author: User

PreviousArticleHttp://blog.csdn.net/norsd/archive/2008/09/13/2921389.aspx implements a webbrowser.

 

However, all things are not perfect. Some netizens recently asked if release is required to implement the functions of the gethtmldocumentx series.

 

At that time, I did not need to answer the question. I thought like this:

 

The webbrowser class only provides one (series) ihtmldocumentx * pointer. In the analysis structure, release. This implementation sounds good, and the actual operation seems no problem.

 

Coincidentally, the problem was finally discovered recently.

 

Consider the following situation:

 

 

1. Open nothere.html

2. If the page cannot be opened, webbrowser will try again.

3. If you jump to another page immediately, webbrowser will generate a new idocument object.

 

At this time, our ihtmldocumentx * Pointer Points to the previous nothere.html

Only get_document can obtain the document of the current page.

 

SoCodeThis should be changed:

Ihtmldocument2 * <br/> webbrowser: gethtmldocument2 () <br/>{< br/> If (_ phtmldoc2! = NULL) <br/> _ phtmldoc2-> release (); <br/> _ phtmldoc2 = NULL; <br/> iwebbrowser2 * pwb2 = NULL; <br/> idispatch * PDP = NULL; </P> <p> nulltest_ AE (pwb2 = getwebbrowser2 ()); <br/> hrtest_e (pwb2-> get_document (& PDP); <br/> nulltest_e (PDP); // if the document does not exist in IE7, then pwb2-> get_document will return an error, but IE6 will not have any HR error, it just makes PDP = NULL. </P> <p> hrtest_e (PDP-> QueryInterface (iid_ihtmldocument2, (void **) & _ phtmldoc2); <br/> return _ phtmldoc2; <br/> return: <br/> return NULL; <br/>}

P.s: ihtmldcoumentx, which indicates ihtmldocument, ihtmldocument2, and so on.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.