Get Favicon from a website for webbrowser control
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts
Page 1 of 1
hello guy's I have a little tutorial for you!
mmm well I put it in this zip and it is free ofcourse
first open vb or visual studio ->
add a picturebox and a webbrowser
set http://www.codenstuff.com as default webbrowser url
set the picturebox size to 24 x 24 to get the perfect size!
and now test it!
+rep if you liked this!
mmm well I put it in this zip and it is free ofcourse
first open vb or visual studio ->
add a picturebox and a webbrowser
set http://www.codenstuff.com as default webbrowser url
Code: Select all
then ad these codes:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("www.codenstuff.com")
End Sub
Code: Select all
that are the codes.Private Sub WebBrowser1_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
Dim response As System.Net.HttpWebResponse
Dim request As System.Net.WebRequest
Dim iconURL As String
Dim favicon As Image
Dim stream As System.IO.Stream
Dim url As Uri = WebBrowser1.Url
If url.HostNameType = UriHostNameType.Dns Then
iconURL = "http://" & url.Host & "/favicon.ico"
request = System.Net.HttpWebRequest.Create(iconURL)
Try
response = request.GetResponse()
stream = response.GetResponseStream()
Catch
For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("link")
If element.GetAttribute("rel").ToUpper = "SHORTCUT ICON" Then
Dim iconplace As String = element.GetAttribute("href")
request = System.Net.HttpWebRequest.Create(WebBrowser1.Url.ToString + iconplace)
response = request.GetResponse()
stream = response.GetResponseStream()
favicon = Image.FromStream(stream)
Me.PictureBox1.Image = favicon
Exit For
End If
Next
End Try
If Not stream Is Nothing Then
favicon = Image.FromStream(stream)
Me.PictureBox1.Image = favicon
End If
End If
end sub
set the picturebox size to 24 x 24 to get the perfect size!
and now test it!
+rep if you liked this!
You do not have the required permissions to view the files attached to this post.
Good Tutorial! but i think this was posted before, still good job
You can find me on Facebook or on Skype mihai_92b
XTechVB wrote:Good Tutorial! but i think this was posted before, still good jobow I am sorry I didn't noticed that blusho;
Yeah, I posted one but it's alright, I think people forgot about it anyway... lol
Keep it up cooll;
Keep it up cooll;
It was also posted in the tutorial "CNS Browser" which is located in the Tuts and Downloads section.
Just find "Tabbed Web Browser" on codenstuff and it has the exact same code
But nice sharing xD

6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023