In Internet Explorer, the DWebBrowserEvents2::NewWindow2 event is not fired when the user selects Window from the New command on the File menu. This event precedes the creation of a new window from within the WebBrowser. For example, DWebBrowserEvents2::NewWindow2 fires in response to a navigation targeted to a new window, or from script using the IHTMLWindow2::open method.
The DWebBrowserEvents2::NewWindow2 event is fired when a window is about to be created, such as during the following actions:
The user clicks a link while pressing the SHIFT key.
The user right-clicks a link and selects Open In New Window.
The user selects New Window from the File menu.
There is a targeted navigation to a frame name that does not yet exist.
Your browser application can also trigger this event by calling the IWebBrowser2::Navigate or IWebBrowser2::Navigate2 method with the navOpenInNewWindow flag. The WebBrowser control has an opportunity to handle the new window creation itself. If it does not, a top-level Internet Explorer window is created as a separate (nonhosted) process.
The application processing this notification can respond in one of three ways:
Create a new, hidden, nonnavigated WebBrowser or InternetExplorer object that is returned in ppDisp. Upon return from this event, the object that fired this event will then configure and navigate (including a BeforeNavigate2 event) the new object to the target location.
Cancel the navigation by setting Cancel to VARIANT_TRUE.
Do nothing and do not set ppDisp to any value. This will cause the object that fired the event to create a new InternetExplorer object to handle the navigation.