Antwise community forums
How to prevent AntView to open a new window? - Printable Version

+- Antwise community forums (https://forums.antwise.com)
+-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11)
+--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12)
+--- Thread: How to prevent AntView to open a new window? (/showthread.php?tid=109)



How to prevent AntView to open a new window? - MrPrzemek - 2022-04-15

Hi

I've been testing your ActiveX in Visual Basic 6 since yesterday
and it seems perfect for me but I can't find the event "OpenNewWindow".

Some pages open new windows when you click on a link.
How to prevent AntView to open a new window?

I want to cancel opening in new window or get url to new navigation.

Old Microsoft WebBrowser Control has event which raise
when a new window is created.

Could you tell me how handle "open new window" event?

Besides, it's great and I will definitely be buying it.

Best regards
VB6 Developer


RE: How to prevent AntView to open a new window? - wila - 2022-04-15

Hello VB6 Developer,

Thanks for the kind words.

The event exists, but is not yet exposed in AntView.
Let me see what I can do for you.

--
Wil


RE: How to prevent AntView to open a new window? - MrPrzemek - 2022-04-17

It would be great if you could add ex. "OnNewWindow" event or property for block opening in new window

Someting like that

Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True 'Disable to open in new window
End Sub


RE: How to prevent AntView to open a new window? - wila - 2022-04-17

Hi,

I wrote the code for that on Friday, but haven't had the chance to test it yet (yesterday, was "no computer day" Wink )
Hopefully later today.

re. your other topic, I will test and come back to that. 

--
Wil


RE: How to prevent AntView to open a new window? - wila - 2022-04-17

MrPrzemek,

Ok, I tested the code I wrote now.

The code to do what you want looks like this:
Code:
Private Sub EdgeWebBrowser_OnNewWindowRequested(ByVal Args As AntViewAx.IAntViewNewWindowRequestedEventArgs)
  Dim URI As String
  Args.Handled = True
  URI = Args.URI
  EdgeWebBrowser.Navigate URI
End Sub

By setting the NewWindowRequest as Handled, you indicate that you are handling this yourself.
One of the other options is to set the "New Window" to use. You can set this to the current EdgeWebBrowser via (EdgeWebBrowser.Dispatch). However when you do that.. it will actually create a new Window within the current browser object and you loose the ability to use history and go back one page.

Instead what I suggest to do is what is in the code snippet above.
First get the URI that was intended to be navigated towards in a new window and then -instead of creating a new window- navigate to it in the current browser object using the Navigate method.

I will get you a private test build later today after I looked into your other questions.

--
Wil


RE: How to prevent AntView to open a new window? - MrPrzemek - 2022-04-19

(2022-04-17, 12:57:55)wila Wrote: MrPrzemek,

Ok, I tested the code I wrote now.

The code to do what you want looks like this:
Code:
Private Sub EdgeWebBrowser_OnNewWindowRequested(ByVal Args As AntViewAx.IAntViewNewWindowRequestedEventArgs)
  Dim URI As String
  Args.Handled = True
  URI = Args.URI
  EdgeWebBrowser.Navigate URI
End Sub

By setting the NewWindowRequest as Handled, you indicate that you are handling this yourself.
One of the other options is to set the "New Window" to use. You can set this to the current EdgeWebBrowser via (EdgeWebBrowser.Dispatch). However when you do that.. it will actually create a new Window within the current browser object and you loose the ability to use history and go back one page.

Instead what I suggest to do is what is in the code snippet above.
First get the URI that was intended to be navigated towards in a new window and then -instead of creating a new window- navigate to it in the current browser object using the Navigate method.

I will get you a private test build later today after I looked into your other questions.

--
Wil

Thank you Wil for sharing me a private biuild.
I confirm. Event OnNewWindowRequested works great

--
Przemek