CHtmlView Interception of new window generation-NEWWINDOW3

Source: Internet
Author: User

When using CHtmlView to write your own browser, if you do not want to click on some links to create a new window, directly in the original window or a new window to display the page, use NEWWINDOW3 intercept and get the page URL

1. First add the following code to the header file of the class

void    NEWWINDOW3 (IDispatch **ppdisp, Variant_bool *Cancel, DWORD DwFlags, BSTR Bstrurlcontext, BSTR bstrURL);D Eclare_ Eventsink_map ()

2. Add the following code to the CPP

Begin_eventsink_map (Myhtmlview, CHtmlView)     273 , NEWWINDOW3, Vts_pdispatch vts_pbool vts_i4 vts_bstr vts_bstr) End_eventsink_map ()

3. Implementation of functions

void MYHTMLVIEW::NEWWINDOW3 (IDispatch **ppdisp, Variant_bool *Cancel, DWORD DwFlags, BSTR Bstrurlcontext, BSTR bstrURL) {     *cancel = TRUE;    Navigate2 (bstrURL);}

Where Cancel is assigned true, the Web page is not automatically opened with the default browser.

bstrURL is the URL of the Web page that is about to open

The resulting bstrurl is used to transfer directly or create a new window yourself.

CHtmlView Interception of new window generation-NEWWINDOW3

Related Article

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.