Article ID: 184876
This article was previously published under Q184876
This article describes how to use the NewWindow2 event, fired by the Microsoft WebBrowser control provided with Microsoft Internet Explorer 4.0, to specify that your browser application should be used in all cases where a new browser window is opened.
This article will describe this procedure using both Visual Basic 5.0 (VB) and the Microsoft Foundation Classes (MFC) that are part of Visual C++ 5.0 (VC).
The NewWindow2 event occurs when a new window is to be created for displaying a resource. This event precedes the creation of a new window from within the WebBrowser control, for example, in response to a navigation targeted to a new window or to a scripted window.open method.
Event handlers for this event receive two out parameters:
In addition, set the RegisterAsBrowser property to TRUE for the newly created WebBrowser control in order for it to participate in window name resolution. For example, if this window name is used elsewhere in script, then this control will be used instead of a newly created one because it checks all of the existing window names before opening a new window.
Here is some sample Visual Basic code to accomplish this:
Using MFC, you may wish to do this in one of three types of applications:
Here is some sample MFC code that would accomplish this task in an SDI or MDI application. This code creates a new frame that contains a WebBrowser control. In an SDI application, this frame would appear to the user to look like another instance of the application. In an MDI application, this frame is the same as if the user had chosen to open a new child window.
For a Microsoft Visual Basic .NET version of this article, see 311282"Reusing the WebBrowser and MSHTML" in the Internet Client SDK Help:
Introduction to Dynamic Styles(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Scott Roberts, Microsoft Corporation.
Article ID: 184876 - Last Review: July 13, 2012 - Revision: 2.0
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Contact us for more help