Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

We have included MS Browser ActiveX control in an MFC component to VB Script. We are using VB script to catch the events fired by ActiveX controls.

What I have tried:

Webbrowser1.Navigate("file:///C:/page.html")


Sub WebBrowser1_NewWindow3(ppDisp, ByRef Cancel, dwFlags, bstrUrlContext, bstrUrl)
'A new, hidden, non-navigated WebBrowser window is needed.
MsgBox("Event NewWindow3 - URL: " + bstrUrl)
Cancel = True
End Sub

Sub WebBrowser1_NewWindow2(ppDisp, ByRef Cancel)
'A new, hidden, non-navigated WebBrowser window is needed.
Cancel = True
MsgBox("Event NewWindow2 - Can't be canceled: " + CStr(Cancel))
End Sub

Sub WebBrowser1_BeforeNavigate2(pDisp,URL,Flags,TargetFrameName,PostData,Headers,Cancel)
'Fired before navigate occurs in the given WebBrowser (window or frameset element). The processing of this navigation may be modified.
MsgBox("Event BeforeNavigate2 - URL: " + URL)
End Sub


From the page we are trying to open a page from new IE window. NewWindow3 event is being fired. But here we set the flag Cancel as true , expecting it should not open new window as we cancelled the navigation. But even with this , new IE window is opening.

is this the right way to prevent navigation for new window? We tried the samething with NewWindow2 as well. We see same result.

Could any one please look into this?
Posted
Updated 30-May-17 19:15pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900