Results 1 to 2 of 2

Thread: Webbrowser Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2010
    Posts
    9

    Exclamation Webbrowser Help

    Please Note: this thread will ask multiple questions so please keep checking the thread.
    Also note: If anyone has other problems with their webbrowser then feel free to ask on this thread as it may help others too!

    Basic Info:
    - No Webbrowser tool used (Tab control was used instead)
    - History is logged into the combobox which is also used to insert the prefered URL.
    -Application is made in Visual Basic 2008

    Problems:
    - History does not log URLS of locations not entered in the Combobox e.g.
    Youtube: when you click a videos image, it takes you to a new page. The history does not log this.
    - Picturebox used for favicon can't always show favicon as the favicon for the specified site isnt always in the same location as other sites
    - Many 3rd party scripting errors occur when on specific sites.

    That is all im going to ask for now.
    Here is the code(below):
    Code:
    Public Class Form1
        Dim int As Integer = 0
    
        Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
            ToolStripProgressBar1.Maximum = e.MaximumProgress
            ToolStripProgressBar1.Value = e.CurrentProgress
        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
            ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
        End Sub
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim ImageList1 As New ImageList
            Dim Browser As New WebBrowser
            TabControl1.TabPages.Add("New Page")
            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.History
                ComboBox1.Items.Add(item)
            Next
    
        End Sub
    
        Private Sub AddTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabToolStripMenuItem.Click
            Dim Browser As New WebBrowser
            TabControl1.TabPages.Add("New Page")
            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 RemoveTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveToolStripMenuItem.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 WebsitePropertiesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebsitePropertiesToolStripMenuItem.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 Button2.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 Button3.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
        End Sub
    
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
        End Sub
    
        Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.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 Button6.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
            My.Settings.History.Add(ComboBox1.Text)
            ComboBox1.Items.Add(ComboBox1.Text)
        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 GoToSiteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToSiteToolStripMenuItem.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
        End Sub
    
        Private Sub CloseWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseWindowToolStripMenuItem.Click
    
            Me.Close()
    
        End Sub
    
        Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
            About.Show()
        End Sub
    
        Private Sub ShortcutsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShortcutsToolStripMenuItem.Click
            Form4.Show()
        End Sub
    
        Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
            BindingSource1.Add(OpenFileDialog1.FileName)
        End Sub
    
        Private Sub Button7_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
            OpenFileDialog1.ShowDialog()
        End Sub
    
        Private Sub ListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            WinPlayer.URL = ListBox1.SelectedItem
        End Sub
    
        Private Sub Button8_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
            WinPlayer.Show()
            Button9.Show()
            ListBox1.Show()
            Button7.Show()
            Button8.Hide()
        End Sub
    
        Private Sub Button9_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
            WinPlayer.Hide()
            Button9.Hide()
            ListBox1.Hide()
            Button7.Hide()
            Button8.Show()
        End Sub
    
        Private Sub DisableToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableToolStripMenuItem.Click
            WinPlayer.Hide()
            Button9.Hide()
            ListBox1.Hide()
            Button7.Hide()
            Button8.Hide()
        End Sub
    
        Private Sub EnableToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnableToolStripMenuItem.Click
            Button8.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
                ComboBox1.Items.Add(item)
            Next
        End Sub
    
        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            If ComboBox1.Text = "Clear All History" Then
                My.Settings.History.Clear()
            End If
    
            If ComboBox1.Text = "Clear All History" Then
                ComboBox1.Items.Clear()
            End If
        End Sub
    End Class

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Webbrowser Help

    Quote Originally Posted by knightVB View Post
    Please Note: this thread will ask multiple questions so please keep checking the thread.
    Also note: If anyone has other problems with their webbrowser then feel free to ask on this thread as it may help others too!
    Please keep each thread to a single topic and each topic to a single thread. Asking and answering lots of different questions in one thread is a great way to make information hard to find. The fact that two questions both relate to a web browser doesn't make them the same topic. The three questions you have asked all belong in separate threads.
    Quote Originally Posted by knightVB View Post
    No Webbrowser tool used (Tab control was used instead)
    That's not True. You have a WebBrowser control on every TabPage in that TabControl.

    I started a Tabbed Web Browser thread in the VB.NET CodeBank forum. Find it using the link in my signature. My code doesn't address your issues but someone else extended my code so theirs might.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width