I am making a web browser using geckofx. I have put the favicon in a picture box but I have changed my mind and now I want it as the form's icon. The code for the favicon is:
Dim oURL As Uri = New Uri(e.Uri.AbsoluteUri)
Dim favicon As Image
If oURL.HostNameType = UriHostNameType.Dns Then
Try
Dim iconURL As String = "http://" & oURL.Host & "/favicon.ico"
Dim request As System.Net.WebRequest = HttpWebRequest.Create(iconURL)
Dim response As HttpWebResponse = request.GetResponse
Dim stream As IO.Stream = response.GetResponseStream
favicon = Image.FromStream(Stream)
Catch
PictureBox1.Image = PictureBox1.ErrorImage
End Try
Try
If favicon Is Nothing Then
Dim result As String = String.Empty
For Each element As GeckoElement In GeckoWebBrowser1.document.DocumentElement.GetElementsByTagName("link")
If element.GetAttribute("REL") = "SHORTCUT ICON" Then
result = element.GetAttribute("HREF")
End If
Next
Dim req As WebRequest = HttpWebRequest.Create(result)
Dim res As HttpWebResponse = req.GetResponse
Dim str As IO.Stream = res.GetResponseStream
favicon = Image.FromStream(str)
End If
Catch ex As Exception
End Try
End If
Try
Me.PictureBox1.Image = favicon
Catch ex As Exception
End Try
The favicon works fine in the picture box but i think it will look better as an icon. If i change the line Me.PictureBox1.Image = favicon to Form1.icon = favicon I get the error Value of type 'System.Drawing.Image' cannot be converted to 'System.Drawing.Icon'.
How can I get this to work?
Thanks in advance!

New Topic/Question
Reply



MultiQuote





|