Web浏览器的图标和网址未显示! [英] Web Browser Icons and url not showing!

查看:145
本文介绍了Web浏览器的图标和网址未显示!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   好的,所以我正在关注Devlob编写的有关如何对Web浏览器进行编程和编码的教程,他添加到Web浏览器中的一件事是图标(例如标签旁边的图标,以便您可以快速查看它是哪个网站)在).

    Okay, so I was following a tutorial by Devlob on how to program and code a web browser, and one of the things that he added to his web browser was icons (like the icons next to the tab so you can quickly see what website it is at).

  他让我添加的另一件事是在url文本框中.发生的事情是,当您在文本框中输入网址时,它将加载该页面并像大多数网络浏览器一样在文本框中显示网址,但是图标和 网址仍然没有出现!

    Another thing he had me add was in the url text box. what was supposed to happen was when you entered a web address into the text box it would load that page and show the url in the text box like most web browsers, but the Icons and the Url still are not appearing!

  所以我仔细检查了我的代码,发现它与他的代码%100相同,但是仍然无法正常工作,然后我用Google对其进行了搜索,找不到任何内容!!!

    So I triple-checked my code and it is %100 the same as his, but It's still not working, then I googled it and could not find anything!!!

  所以这是我的代码:

    So here is my code:

Imports System.Net
Imports System.IO

Public Class frmSurfabl

    Private Sub ToolsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ToolsToolStripMenuItem.Click

    End Sub

    Private Sub frmSurfabl_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cmbSearchEngines.Items.Add("Google")
        cmbSearchEngines.Items.Add("Yahoo")
        cmbSearchEngines.Items.Add("Bing")
        cmbSearchEngines.Items.Add("DuckDuck Go")
        cmbSearchEngines.Items.Add("YouTube")
        cmbSearchEngines.Items.Add("Wikipedia")

        cmbSearchEngines.SelectedIndex = 0

        WebBrowser1.Navigate(My.Settings.homePage)

    End Sub

    Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
        WebBrowser1.GoBack()
    End Sub

    Private Sub bnForward_Click(sender As Object, e As EventArgs) Handles bnForward.Click
        WebBrowser1.GoForward()
    End Sub

    Private Sub btnRefresh_Click(sender As Object, e As EventArgs) Handles btnRefresh.Click
        WebBrowser1.Refresh()
    End Sub

    Private Sub txtUrl_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUrl.KeyUp
        If e.KeyCode = Keys.Enter Then
            WebBrowser1.Navigate(txtUrl.Text)
        End If
    End Sub

    Private Sub webIcons()
        Dim wc As New WebClient
        Dim memorystream As New MemoryStream(wc.DownloadData("http://" & New Uri(WebBrowser1.Url.ToString).Host & "/favicon.ico"))
        Dim icon As New Icon(memorystream)

        If ImageList1.Images.Count = -1 Then
            ImageList1.Images.Add(icon.ToBitmap)
            TabControl1.SelectedTab.ImageIndex = 0
        Else
            ImageList1.Images.Clear()
            ImageList1.Images.Add(icon.ToBitmap)
            TabControl1.SelectedTab.ImageIndex = 0
        End If
    End Sub

    Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs)
        txtUrl.Text = WebBrowser1.Url.ToString
        webIcons()
        TabControl1.SelectedTab.Text = WebBrowser1.DocumentTitle.ToString
    End Sub

    Private Sub txtUrlSearchEngines_KeyUp(sender As Object, e As KeyEventArgs) Handles txtUrlSearchEngines.KeyUp
        Select Case (cmbSearchEngines.SelectedIndex)
            Case 0
                If e.KeyCode Then
                    WebBrowser1.Navigate("https://www.google.com/#q=" + txtUrlSearchEngines.Text)
                End If
            Case 1
                If e.KeyCode Then
                    WebBrowser1.Navigate("https://search.yahoo.com/search;_ylc=X3oDMTFiN25laTRvBF9TAzIwMjM1MzgwNzUEaXRjAzEEc2VjA3NyY2hfcWEEc2xrA3NyY2h3ZWI-?p=" + txtUrlSearchEngines.Text)
                End If
            Case 2
                If e.KeyCode Then
                    WebBrowser1.Navigate("http://www.bing.com/search?q=" + txtUrlSearchEngines.Text)
                End If
            Case 3
                If e.KeyCode Then
                    WebBrowser1.Navigate("https://duckduckgo.com/?q=" + txtUrlSearchEngines.Text)
                End If
            Case 4
                If e.KeyCode Then
                    WebBrowser1.Navigate("https://www.youtube.com/results?search_query=" + txtUrlSearchEngines.Text)
                End If
            Case 5
                If e.KeyCode Then
                    WebBrowser1.Navigate("https://en.wikipedia.org/wiki/Special:Search?search=" + txtUrlSearchEngines.Text)
                End If
        End Select
    End Sub

    Private Sub btnHome_Click(sender As Object, e As EventArgs) Handles btnHome.Click
        WebBrowser1.Navigate(My.Settings.homePage)
    End Sub
End Class

  我们将不胜感激!

    Any help would be appreciated!

推荐答案

我建​​议使用图标,在webIcons的第一行设置一个断点,并逐步执行代码,确保内存流首先工作,然后继续单步执行其余代码行的代码,以查看其是否按预期方式流动.
I would suggest for the icons, set a break point on the first line of webIcons and step through the code, ensure that the memory stream works first then continue stepping through the code for the remaining line of code to see if it flows as intended.


这篇关于Web浏览器的图标和网址未显示!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆