[VB 2005 Express] New Window In Web Browser

Azreal

Member
Joined
Oct 4, 2006
Messages
19
Programming Experience
Beginner
Hello, I am having dificulties with the web browser control in Visual Basic 2005 Express Edition. I have this checkbox and when it is enabled it makes my boolean true, and it makes it so popups are not allowed. But I press Ctrl+N in the program Interent Explorer opens up! How do I fix this?

Here is part of my code:

VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] PopupCheck [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Load[/SIZE]
[SIZE=2]CheckPops.Checked = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][COLOR=black][COLOR=blue][SIZE=2]Private [/SIZE][SIZE=2]Sub[/SIZE][/COLOR][SIZE=2] CheckPops_CheckedChanged([/SIZE][SIZE=2][COLOR=blue]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=blue]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=blue]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=blue]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][/COLOR][SIZE=2][COLOR=blue]Handles[/COLOR][/SIZE][SIZE=2][COLOR=black] CheckPops.CheckedChanged[/COLOR][/SIZE]
[SIZE=2][COLOR=black]If[/COLOR][/SIZE][SIZE=2][COLOR=black] CheckPops.Checked =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=black]PopupCheck =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=black]wb1.ScriptErrorsSuppressed =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=black]PopupCheck =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=black]wb1.ScriptErrorsSuppressed =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff][COLOR=black][COLOR=blue][SIZE=2]Private [/SIZE][SIZE=2]Sub[/SIZE][/COLOR][SIZE=2] wb1_NewWindow([/SIZE][SIZE=2][COLOR=blue]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=blue]As [/COLOR][/SIZE][SIZE=2]Object[/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=blue]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=blue]As[/COLOR][/SIZE][SIZE=2] System.ComponentModel.CancelEventArgs) [/SIZE][/COLOR][SIZE=2][COLOR=blue]Handles[/COLOR][/SIZE][SIZE=2][COLOR=black] wb1.NewWindow[/COLOR][/SIZE]
 
[SIZE=2][SIZE=2][COLOR=#008000]' Popup Blocker[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] [COLOR=black]PopupCheck =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]False [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=black]lblPops.Visible =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=black]Timer1.Enabled =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=black]Cancel =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Exit [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] [COLOR=black]PopupCheck = [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] [COLOR=black]frmMe[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] [COLOR=black]frmBrowser[/COLOR][/SIZE]
[SIZE=2][COLOR=black]frmMe.Text =[/COLOR] [/SIZE][SIZE=2][COLOR=#800000]"New Window"[/COLOR][/SIZE]
[SIZE=2][COLOR=black]frmMe.Show()[/COLOR][/SIZE]
[SIZE=2][COLOR=black]frmMe.wb1.Navigate([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2][COLOR=black].[/COLOR][COLOR=black]Tag)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Exit [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/SIZE][COLOR=black][COLOR=blue][SIZE=2]End [/SIZE][SIZE=2]Sub[/SIZE][/COLOR][/COLOR]
 
[COLOR=black][COLOR=blue][SIZE=2][SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] [COLOR=black]wb1_StatusTextChanged([/COLOR][/SIZE][COLOR=black][SIZE=2][COLOR=blue]ByVal [/COLOR][/SIZE][SIZE=2]sender [/SIZE][SIZE=2][COLOR=blue]As [/COLOR][/SIZE][SIZE=2]Object[/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=blue]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=blue]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][/COLOR][SIZE=2][COLOR=blue]Handles[/COLOR][/SIZE][SIZE=2][COLOR=black] wb1.StatusTextChanged[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] InStr[COLOR=black](wb1.StatusText,[/COLOR] [/SIZE][SIZE=2][COLOR=#800000]"http://"[/COLOR][/SIZE][SIZE=2][COLOR=black])[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2][COLOR=black].Tag = wb1.StatusText[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
[COLOR=green]' I have my own context menu[/COLOR]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2][COLOR=#000000] ToolStripMenuItem2_Click([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#000000] sender [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#000000] System.Object, [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2][COLOR=#000000] e [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#000000] System.EventArgs) [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#000000] ToolStripMenuItem2.Click[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' Popup Blocker[/COLOR][/SIZE]
[SIZE=2][COLOR=black]If[/COLOR][/SIZE][SIZE=2][COLOR=black] PopupCheck =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]False [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=black]lblPops.Visible =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=black]Timer1.Enabled =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][SIZE=2] [COLOR=black]PopupCheck =[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]True [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] [COLOR=black]frmMe[/COLOR] [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] [COLOR=black]frmBrowser[/COLOR][/SIZE]
[SIZE=2][COLOR=black]frmMe.Text =[/COLOR] [/SIZE][SIZE=2][COLOR=#800000]"New Window"[/COLOR][/SIZE]
[SIZE=2][COLOR=black]frmMe.Show()[/COLOR][/SIZE]
[SIZE=2][COLOR=black]frmMe.wb1.Navigate([/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2][COLOR=black].Tag)[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][/SIZE][/COLOR][/COLOR][/COLOR][/SIZE][/COLOR][/SIZE]
[/COLOR][/SIZE][/COLOR][/SIZE]
 
You probably figured it out by now... In NewWindow event you set Cancel, but I can't see that you have declared this variable anywhere in posted code.. it should perhaps be e.Cancel? Using the Cancel property of the events e parameter (type CancelEventArgs).
 
Back
Top