Computing.Net > Forums > Programming > WebBrowser Control in VB6

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

WebBrowser Control in VB6

Reply to Message Icon

Original Message
Name: Burbble
Date: December 17, 2002 at 14:24:25 Pacific
Subject: WebBrowser Control in VB6
OS: Windows ME
CPU/Ram: Celeron 600mhz / 384 MB
Comment:

Hi,

I've tried many different ways to figure this out, but I simply cannot! Perhaps someone else can...

I am trying to use the NewWindow2 event of the WebBrowser Control in Visual Basic 6. In the event, there is a "ppDisp as Object" parameter which I cannot figure out how to use. I want it to create another form from my program when a NewWindow2 event is executed, instead of an Internet Explorer window appearing. I looked through Microsoft's site and found this, but it didn't help me. Perhaps it will help you?

-----

The 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 Navigate or 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 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.

-----

I know how to prevent anything from happening, but I want another form from my program to appear instead of an Internet Explorer window.

Thanks for your help!

-Burbble


Report Offensive Message For Removal


Response Number 1
Name: HiJinx
Date: December 17, 2002 at 16:07:40 Pacific
Reply: (edit)

If you want a new form identical to the current one, you'd use something like the following:

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)

Dim frmNew As Form1

Set frmNew = New Form1

Set ppDisp = frmNew.WebBrowser1.Object

frmNew.Show

End Sub


Report Offensive Follow Up For Removal

Response Number 2
Name: Burbble
Date: December 18, 2002 at 03:57:27 Pacific
Reply: (edit)

Thanks! It's so simple; I was omitting the ".Object" on the "Set ppDisp =" line.

Thanks again for your help!

-Burbble


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software