none
Ayuda con un navegador de pestañas con el PopUp RRS feed

  • Pregunta

  • Public Class Form1
      Dim int As Integer = 0
      Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
        TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
        ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
      End Sub
    
      Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
      End Sub
    
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Form1_Load:
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("Nueva Pestaña")
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
    
        For Each item As String In My.Settings.Marcadores
          MarcadoresToolStripMenuItem.DropDownItems.Add(item)
        Next
        For Each item As String In My.Settings.History
          Form3.ListBox1.Items.Add(item)
        Next
    
        My.Settings.History.Add(ComboBox1.Text)
        Form3.ListBox1.Items.Add(Me.ComboBox1.Text)
    
      End Sub
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
      End Sub
    
      Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox6.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
      End Sub
    
      Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
      End Sub
    
      Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
    
        My.Settings.History.Add(ComboBox1.Text)
        Form3.ListBox1.Items.Add(Me.ComboBox1.Text)
      End Sub
    
      Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    
      End Sub
    
      Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
    
      End Sub
    
      Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("Nueva Pestaña")
        TabControl1.SelectTab(int)
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
      End Sub
    
      Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        If Not TabControl1.TabPages.Count = 1 Then
          TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
          TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
          int = int - 1
        End If
      End Sub
    
      Private Sub PropiedadesWebToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
      End Sub
    
      Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).StatusText
      End Sub
    
      Private Sub PegarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PegarToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Document.ExecCommand("Paste", False, vbNull)
      End Sub
    
      Private Sub CopiarToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopiarToolStripMenuItem1.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Document.ExecCommand("Copy", False, vbNull)
      End Sub
    
      Private Sub CortarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CortarToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Document.ExecCommand("Cut", False, vbNull)
      End Sub
    
      Private Sub MarcadoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MarcadoresToolStripMenuItem.Click
    
      End Sub
    
      Private Sub CambiarPaginaDeInicioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CambiarPaginaDeInicioToolStripMenuItem.Click
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("Nueva Pestaña")
        TabControl1.SelectTab(int)
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
      End Sub
    
      Private Sub CerrarVentanaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CerrarVentanaToolStripMenuItem.Click
        Me.Close()
      End Sub
    
      Private Sub CerrarPestañaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CerrarPestañaToolStripMenuItem.Click
        If Not TabControl1.TabPages.Count = 1 Then
          TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
          TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
          int = int - 1
        End If
      End Sub
    
      Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        Me.Close()
      End Sub
    
      Private Sub PropiedadesDeLaWebToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PropiedadesDeLaWebToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
      End Sub
      Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click
        WebBrowser2.Navigate("http://www.los40.com/player/Radio/40Principales/")
      End Sub
    
      Private Sub ToolStripMenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem9.Click
        WebBrowser2.Navigate("http://www.maxima.fm/multimedia/radios.html")
      End Sub
    
      Private Sub ToolStripMenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem8.Click
        WebBrowser2.Navigate("http://www.europafm.com/EuropaFM/enDirecto/Formula-Europa-FM/1702998")
      End Sub
    
      Private Sub ToolStripMenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem11.Click
        WebBrowser2.Navigate("http://www.google.es")
      End Sub
    
      Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click
        WebBrowser2.Navigate("http://www.cope.es/player.php5")
      End Sub
    
      Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
        WebBrowser2.Navigate("http://www.m80radio.com/multimedia/radios.html")
      End Sub
    
      Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click
        WebBrowser2.Navigate("http://www.ondacero.es/OndaCero/emisionEnDirecto")
      End Sub
    
      Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
        WebBrowser2.Navigate("http://player.cadena100.es/")
      End Sub
    
      Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
        WebBrowser2.Navigate("http://www.cadenaser.com/player_radio.html")
      End Sub
    
      Private Sub ToolStripMenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem10.Click
        WebBrowser2.Refresh()
      End Sub
    
      Private Sub AñadirMarcadoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AñadirMarcadoresToolStripMenuItem.Click
        Form2.Show()
      End Sub
    
      Private Sub EliminarTodosLosMarcadoresToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EliminarTodosLosMarcadoresToolStripMenuItem.Click
        My.Settings.Marcadores.Clear()
      End Sub
    
      Private Sub HistorialToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HistorialToolStripMenuItem.Click
        Form3.Show()
      End Sub
    
      Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        For Each item As String In My.Settings.History
          Form3.ListBox1.Items.Add(item)
        Next
      End Sub
    
      Private Sub ToolStripMenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem12.Click
        My.Settings.History.Clear()
        ComboBox1.Items.Clear()
        Form3.ListBox1.Items.Clear()
      End Sub
    End Class
    

    He mirado varios tutoriales en Ingles, pero no entiendo nada. La idea es que al clicar en un vinculo con el boton derecho le des a Abrir en Nueva ventana y te la abra en una nueva ventana de Mi navegador, no del IE. Lo mismo con abrir en una nueva pestaña. Me ayudais? Lo unico que encuentro en español es de VB 06.

    Gracias por adelantado.

    domingo, 6 de junio de 2010 15:29

Respuestas

Todas las respuestas

  • hola

    no has probado atrapando el evento NewWindow2 del control WebBrowser ?

    algo como lo comentado en este link

    Open link in new TAB (WebBrowser Control)

    Cómo utilizar el evento de control NewWindow2 WebBrowser en Visual Basic.NET

     

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina
    domingo, 6 de junio de 2010 15:59
  • El primer link es C, yo programo en visual basic, en cuanto al segundo no entiendo mucho de ingles.

    Muchas gracias por responder ; )

    domingo, 6 de junio de 2010 16:42
  • hola

    ups sin ingles aunque sea basico estamos complicados, pero recuerda que podrias poner el link en google tanslator para poder verlo en español

    http://www.google.com.ar/language_tools?hl=es

     

    en el link de c#, me olvide de comentar que el codigo puedes traducirlo ayudandote de estas tools

    Convert C# to VB.NET

    Code Converter

     

    igua ese link era solo para mostrar que podrias usar el evento NewWindow2 para atrapar la ventana, has una prueba simple al control WebBrowser agregale este evento y luego pon un breakpoint alli para ver si se lanza cuando abres la ventana, si se detiene el codigo alli es porque funciona

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina
    domingo, 6 de junio de 2010 16:59
  • Introduzco este código:

    Public Class Form1
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      AxWebBrowser1.Navigate(TextBox1.Text)
     End Sub
     Private Sub AxWebBrowser1_NewWindow2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NewWindow2Event) Handles AxWebBrowser1.NewWindow2
      Dim frmWB As Form1
      frmWB = New Form1()
    
      frmWB.AxWebBrowser1.RegisterAsBrowser = True
      e.ppDisp = frmWB.AxWebBrowser1.Application
      frmWB.Visible = True
     End Sub
    End Class

    Pero, me da errores.

    Error    1:    No se ha declarado el nombre 'AxWebBrowser1'.    C:\Documents and Settings\Administrador\Configuración local\Datos de programa\Temporary Projects\Test\Form1.vb    4    9    Test

    Error    2 :   El tipo 'AxSHDocVw.DWebBrowserEvents2_NewWindow2Event' no está definido.    C:\Documents and Settings\Administrador\Configuración local\Datos de programa\Temporary Projects\Test\Form1.vb    7    77    Test


    Error    3:    La cláusula Handles requiere una variable WithEvents definida en el tipo contenedor o en uno de sus tipos base.    C:\Documents and Settings\Administrador\Configuración local\Datos de programa\Temporary Projects\Test\Form1.vb    7    131    Test

    Error    4:    'AxWebBrowser1' no es un miembro de 'Test.Form1'.    C:\Documents and Settings\Administrador\Configuración local\Datos de programa\Temporary Projects\Test\Form1.vb    11    9    Test

    Error    5:    'AxWebBrowser1' no es un miembro de 'Test.Form1'.    C:\Documents and Settings\Administrador\Configuración local\Datos de programa\Temporary Projects\Test\Form1.vb    12    20    Test

    También es cierto, que no he hecho este paso:

    Haga clic con el botón secundario en el panel abrir y, a continuación, haga clic en Personalizar cuadro de herramientas .

    Yo no tengo ningun abrir. Y si se refiere a la carpeta de arriba de Abrir Archivo, no tengo ningun Explorador Web de Microsoft, ni siquiera un boton aceptar

    domingo, 6 de junio de 2010 17:14
  • hola

    pero el control WebBrowser que estas suando se llama AxWebBrowser1  ?

     

    recuerda que esto son ejemplos que debes adaptar a tu codigo, no puede copiar y pegar asi como esta

    cuando ves AxWebBrowser1 esta indicando que es el nombre de tu control WebBrowser que ahs puesto en tu form el que debes usar

     

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina
    domingo, 6 de junio de 2010 22:52
  • Que tonto xD.

    Gracias, en seguida lo pruebo

    sábado, 12 de junio de 2010 14:30
  • Hola!

    Fue posible solucionar su problema?

    Gracias
    Rafael Fagundes - Marque la respuesta como correcta si te ha sido de utilidad!
    martes, 22 de junio de 2010 2:39
    Moderador