Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WebBrowser and WebBrowser_V1

186 views
Skip to first unread message

Colin Messitt

unread,
Jun 5, 1998, 3:00:00 AM6/5/98
to

Microsoft Knowledgebase article Q185538, which I've copied the relevant
parts of on the bottom here, explains how to cause the IE4 Webbrowser
control to also fire IE3 events. This is required because the IE4 WebBrowser
doesn't provide the URL on a NewWindow2 Event, and it's therefore impossible
to cancel the new window and cause navigation in the original window. It
also shows how to catch those IE3 events, but it is explained in VB terms,
and I know nothing about VB! Does anybody know how to do this in Delphi?

TIA,

Colin.

SUMMARY
=======

When hosting the Internet Explorer 4.x WebBrowser control in a Visual Basic
application, you may want to have the navigation always occur in your
application and not other Internet Explorer windows. If you handle the
NewWindow2 event and set the Cancel flag equal to True, navigation is
canceled completely. Since NewWindow2 does not provide you with the URL to
navigate to as the Internet Explorer 3.x NewWindow event did, there doesn't
appear to be any way to have the navigation occur in the same window.

Fortunately, Internet Explorer 4.x provides the WebBrowser_V1 object for
compatibility with Internet Explorer 3.x. Using the WebBrowser_V1 object,
you can have your application receive both version 3.x and version 4.x
events. That means that you can handle the version 3.x NewWindow event and
then have the navigation occur in the current window.

Please note that Internet Explorer does not fire a NewWindow or NewWindow2
event when the user presses CTRL+N or points to New from the File and
clicks Window.

MORE INFORMATION
================

In order to implement this functionality in your Visual Basic application,
follow these step:

1. Create a form with a WebBrowser control on it.

2. In the declarations section of that form, add the following:

Dim WithEvents Web_V1 as SHDocVwCtl.WebBrowser_V1

This will declare a WebBrowser_V1 variable that can receive events
WebBrowser_V1 provides you with the NewWindow event.

3. In the Form_Load event, add the following:

Set Web_V1 = WebBrowser1.Object

This sets the WebBrowser_V1 object to the existing Internet Explorer 4.x
WebBrowser object.

4. After the NewWindow2 event fires, the Web_V1_NewWindow event will fire
with the linked URL as one of its input arguments. Remember not to set
Cancel to True in NewWindow2. Also, set the Processed variable to True
in the NewWindow event handler so that a new instance of Internet
Explorer 4 will not be created. The following code shows this event
handler and the code necessary to navigate within the current window:

Private Sub Web_V1_NewWindow(ByVal URL As String, _
ByVal Flags As Long, _
ByVal TargetFrameName As String, _
PostData As Variant, _
ByVal Headers As String, _
Processed As Boolean)
Processed = True
WebBrowser1.Navigate URL
End Sub


0 new messages