none
sobre un navegador RRS feed

  • Pregunta

  • estoy realizando un navegador y si me reproduce el problema es que al cerrar el navegador la el video de youtube sigue reproduciendoce como hago para que se cierre

    mi codigo lo tengo haci

    Imports System.Net
    Imports System.Data.OleDb
    Imports System.Xml
    Public Class NAVEGADOR

    #Region "enumerados"

        Private Enum Exec
            OLECMDID_OPTICAL_ZOOM = 63
            OLECMID_CUT = 11
            OLECMID_COPY = 12
            OLECMID_PASTE = 13
            OLECMDID_DELETE = 33
            OLECMDID_SELECTALL = 17
            OLECMDID_FIND = 32
        End Enum

        Private Enum ExecOpt
            OLECMDEXECOPT_DODEFAULT = 0
            OLECMDEXECOPT_PROMPTUSER = 1
            OLECMDEXECOPT_DONPROMPTUSER = 2
            OLECMDEXECOPT_SHOWHELP = 3
        End Enum
    #End Region

    #Region "Variables"
        Dim i As Integer = 0
        Dim valorZoom As String = 100
    #End Region


    #Region "FuncionesAgregadas"
        'Procedimiento NuevaPestaña 
        'modo = 0 ; entonces irá a la página de inicio
        'modo = 1; entonces duplicara la pestaña
        Public Sub NuevaPestaña(ByVal modo As Byte, url As String)
            Dim browser As New WebBrowser
            TabControl1.TabPages.Add("Nueva pestaña")
            TabControl1.SelectTab(i)
            browser.Name = "Navegador"
            browser.Dock = DockStyle.Fill
            TabControl1.SelectedTab.Controls.Add(browser)
            AddHandler browser.ProgressChanged, AddressOf Loading
            AddHandler browser.DocumentCompleted, AddressOf Done
            i = i + 1
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ScriptErrorsSuppressed = True
            If modo = 0 Then
                CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(leerHome)
            Else
                CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(url)
            End If

        End Sub

        Function leerHome()
            Dim myXmlDocument As New XmlDocument()
            myXmlDocument.Load(My.Application.Info.DirectoryPath + "\home.xml")
            Dim node As XmlNode
            node = myXmlDocument.DocumentElement
            Return node.ChildNodes.Item(0).InnerText
        End Function

        Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
            Try
                progreso_ProgressBar.Maximum = e.MaximumProgress
                progreso_ProgressBar.Value = e.CurrentProgress
            Catch ex As Exception

            End Try
        End Sub

        Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
            TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
            urlTextBox.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
        End Sub

        Private Sub HacerZoom(ByVal valor As String)
            Try
                Dim res As Object = Nothing
                Dim MyWeb As Object
                MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
                MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, ExecOpt.OLECMDEXECOPT_PROMPTUSER, Integer.Parse(valor))
            Catch ex As Exception
                MessageBox.Show(ex.Message.ToString)
            End Try
        End Sub
    #End Region





    #Region "OtrosEventos"

        Private Sub TabControl1_Selected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlEventArgs)
            Try
                urlTextBox.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
            Catch ex As Exception
            End Try
        End Sub

        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        End Sub

        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            estadoLabel.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).StatusText
        End Sub

    #End Region

    #Region "EventoLoad"
        Private Sub Principal_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            TabControl1.TabPages.Add("Nueva pestaña")
            Dim browser As New WebBrowser
            browser.Name = "Navegador"
            browser.Dock = DockStyle.Fill
            TabControl1.SelectedTab.Controls.Add(browser)
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ScriptErrorsSuppressed = True
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(leerHome)
            AddHandler browser.ProgressChanged, AddressOf Loading
            AddHandler browser.DocumentCompleted, AddressOf Done
            i = i + 1
        End Sub
    #End Region

    #Region "MenuArchivo"
        Private Sub AñadirPestañaMI_Click(sender As System.Object, e As System.EventArgs) Handles AñadirPestañaMI.Click
            NuevaPestaña(0, Nothing)
        End Sub

        Private Sub DuplicarPestañaMI_Click(sender As System.Object, e As System.EventArgs) Handles DuplicarPestañaMI.Click
            NuevaPestaña(1, urlTextBox.Text)
        End Sub

        Private Sub QuitarPestañaMI_Click(sender As System.Object, e As System.EventArgs) Handles QuitarPestañaMI.Click
            If Not TabControl1.TabPages.Count = 1 Then
                'Liberamos los recursos usados por el control 
                CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Dispose()
                'Removemos el tabPage del tabcontrol
                TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
                'Actualizamos el tab seleccionado 
                TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
                i = i - 1
            End If
        End Sub

        Private Sub NuevaVentanaMI_Click(sender As System.Object, e As System.EventArgs) Handles NuevaVentanaMI.Click
            Dim nueva As New PORTADA
            nueva.StartPosition = FormStartPosition.CenterParent
            nueva.Show()
        End Sub

        Private Sub AbrirMI_Click(sender As System.Object, e As System.EventArgs) Handles AbrirMI.Click
            OpenFileDialog1.Title = "Abrir archivo"
            OpenFileDialog1.FileName = ""
            OpenFileDialog1.Filter = "Paginas web(*.html)|*.html|Paginas web(*.mth)|*.mht|Paginas web(*.aspx)|*.aspx"
            OpenFileDialog1.ShowDialog()
            Dim url As String = OpenFileDialog1.FileName
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(url)
            urlTextBox.Text = url
        End Sub

        Private Sub GuardarComoMI_Click(sender As System.Object, e As System.EventArgs) Handles GuardarComoMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowSaveAsDialog()
        End Sub

        Private Sub ConfigurarPaginaMI_Click(sender As System.Object, e As System.EventArgs) Handles ConfigurarPaginaMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPageSetupDialog()
        End Sub


        Private Sub VistaPreviaMI_Click(sender As System.Object, e As System.EventArgs) Handles VistaPreviaMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPrintPreviewDialog()
        End Sub

        Private Sub ImprimirMI_Click(sender As System.Object, e As System.EventArgs) Handles ImprimirMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPrintDialog()
        End Sub

        Private Sub PropiedadesMI_Click(sender As System.Object, e As System.EventArgs) Handles PropiedadesMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
        End Sub

        Private Sub SalirMI_Click(sender As System.Object, e As System.EventArgs)
            Me.Close()
        End Sub
    #End Region

    #Region "MenuEdicion"
        Private Sub CortarMI_Click(sender As System.Object, e As System.EventArgs) Handles CortarMI.Click
            Dim MyWeb As Object
            MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
            MyWeb.ExecWB(Exec.OLECMID_CUT, ExecOpt.OLECMDEXECOPT_DONPROMPTUSER)
        End Sub

        Private Sub CopiarMI_Click(sender As System.Object, e As System.EventArgs) Handles CopiarMI.Click
            Dim MyWeb As Object
            MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
            MyWeb.ExecWB(Exec.OLECMID_COPY, ExecOpt.OLECMDEXECOPT_DONPROMPTUSER)
        End Sub

        Private Sub PegarMI_Click(sender As System.Object, e As System.EventArgs) Handles PegarMI.Click
            Dim MyWeb As Object
            MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
            MyWeb.ExecWB(Exec.OLECMID_PASTE, ExecOpt.OLECMDEXECOPT_DONPROMPTUSER)
        End Sub

        Private Sub BorrarMI_Click(sender As System.Object, e As System.EventArgs) Handles BorrarMI.Click
            Try
                Dim res As Object = Nothing
                Dim MyWeb As Object
                MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
                MyWeb.ExecWB(Exec.OLECMDID_DELETE, ExecOpt.OLECMDEXECOPT_DONPROMPTUSER)
            Catch ex As Exception
                MessageBox.Show(ex.Message.ToString)
            End Try
        End Sub

        Private Sub BuscarMI_Click(sender As System.Object, e As System.EventArgs) Handles BuscarMI.Click
            Dim MyWeb As Object
            MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
            MyWeb.ExecWB(Exec.OLECMDID_FIND, ExecOpt.OLECMDEXECOPT_PROMPTUSER)
        End Sub

        Private Sub SeleccionarTodoMI_Click(sender As System.Object, e As System.EventArgs) Handles SeleccionarTodoMI.Click
            Dim MyWeb As Object
            MyWeb = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ActiveXInstance
            MyWeb.ExecWB(Exec.OLECMDID_SELECTALL, ExecOpt.OLECMDEXECOPT_DONPROMPTUSER)
        End Sub
    #End Region

    #Region "MenuVer"
        Private Sub AumentarZoomMI_Click(sender As System.Object, e As System.EventArgs) Handles AumentarZoomMI.Click
            If valorZoom = 1000 Then
                Return
            End If
            valorZoom += 25
            ComboBox1.Text = valorZoom.ToString + "%"
            HacerZoom(valorZoom)
        End Sub

        Private Sub DisminuirZoomMI_Click(sender As System.Object, e As System.EventArgs) Handles DisminuirZoomMI.Click
            If valorZoom = 25 Then
                Return
            End If
            valorZoom -= 25
            ComboBox1.Text = valorZoom.ToString + "%"
            HacerZoom(valorZoom)
        End Sub

        Private Sub PaginaDeInicioMI_Click(sender As System.Object, e As System.EventArgs) Handles PaginaDeInicioMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
        End Sub

        Private Sub PaginaActualMI_Click(sender As System.Object, e As System.EventArgs) Handles PaginaActualMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(urlTextBox.Text)
        End Sub
        Private Sub DetenerMI_Click(sender As System.Object, e As System.EventArgs) Handles DetenerMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
        End Sub

        Private Sub ActualizarMI_Click(sender As System.Object, e As System.EventArgs) Handles ActualizarMI.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
        End Sub



    #End Region


        Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
            PORTADA.Show()
            Me.Hide()
        End Sub

        Private Sub TabControl1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles TabControl1.SelectedIndexChanged

        End Sub

        Private Sub HomeBtn_Click(sender As System.Object, e As System.EventArgs) Handles HomeBtn.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
        End Sub


        Private Sub AtrasBtn_Click(sender As System.Object, e As System.EventArgs) Handles AtrasBtn.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
        End Sub

        Private Sub AdelanteBtn_Click(sender As System.Object, e As System.EventArgs) Handles AdelanteBtn.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
        End Sub

        Private Sub ActualizarBtn_Click(sender As System.Object, e As System.EventArgs) Handles ActualizarBtn.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
        End Sub

        Private Sub GoBtn_Click(sender As System.Object, e As System.EventArgs) Handles GoBtn.Click
            ''Si el campo URL esta vacio
            If urlTextBox.Text.Trim(" ") = "" Then
                Return
            End If
            'Navego a la pagina web
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(urlTextBox.Text)

        End Sub

        Private Sub urlTextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles urlTextBox.TextChanged

        End Sub


    End Class

    sábado, 22 de abril de 2017 4:54