|
-
Jun 22nd, 2006, 02:48 PM
#1
Thread Starter
Hyperactive Member
-
Jun 22nd, 2006, 04:50 PM
#2
Lively Member
Re: [2005] Favicon.ico in VB.NET?
If you look in the source, a website with a favicon file will have one or more of the following tags in the <head> section:
<link rel="icon" href="http://example.com/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://example.com/favicon.ico" type="image/x-icon" />
More info about it can be found on the wikipedia page.
You can parse the source of the document checking to see if there is a <link> tag and if the "rel" property contains "icon" or "shortcut icon". It might be possible to use the XML class to do this, I've never actually tried it myself, but XML is just customizable HTML anyway.
Once you parse out the path to the image, you can use the System.Net.WebClient class to download the image to a temporary path and then set the Textbox's image or background image property (does it have one?) to the file using Bitmap.FromFile() and the ImageAlign property to MiddleLeft (again, does it have that?). If there aren't those properties, you can still do it using the paint event or creating your own drawing surface.
-
Jun 22nd, 2006, 05:51 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Favicon.ico in VB.NET?
Well I got the webclient to work, I don't know how to parse the webbrowser's document....any links? (in the meantime I will be searching). I downloaded the file but I cannot set the textbox's property to show the image. How could I use the paint event/creating my own drawing surface?
"Imagination is more important than knowledge" - Albert Einstein, born on March 14th 1879.
Can't find it here on VBForums? Go to the CodeProject. MSDN is your friend . I have such a bad website, my friend decided it would be funny to change the template and he moderates the site for me: visit my site!
"Thinking of you, wherever you are
We pray for our sorrows to end, and hope that our hearts will blend.
Now I will step forward to realize this wish.
And who knows, starting a new journey may not be so hard…
Or maybe it has already begun.
There are many worlds, but they share the same sky
one sky, one destiny..."
-
Jun 22nd, 2006, 06:13 PM
#4
Lively Member
Re: [2005] Favicon.ico in VB.NET?
You basically need to just go through the WebBrowser.DocumentText looking for a <link tag, and if has rel="icon" or rel="shortcut icon" before the next > (the closing tag) then it is a favicon link, and you can search for the href=" part of the tag and download the image using the webclient.
And I'm not really a heavy GDI user, so I'm not entirely sure how you can draw the image onto the textbox. I see now that it doesn't have any image properties like a label does, so you will have to do that. Try searching the forums for GDI programming, I'm sure they're something you can use for that portion. But first you need to get the image downloaded. You might also want to just use an ImageCombo if you are using this for a browser address bar. Then it would be easy to add the image to the current item.
-
Jun 22nd, 2006, 06:57 PM
#5
Thread Starter
Hyperactive Member
Re: [2005] Favicon.ico in VB.NET?
Could you explain what you meant by ImageCombo?
You might also want to just use an ImageCombo if you are using this for a browser address bar. Then it would be easy to add the image to the current item.
"Imagination is more important than knowledge" - Albert Einstein, born on March 14th 1879.
Can't find it here on VBForums? Go to the CodeProject. MSDN is your friend . I have such a bad website, my friend decided it would be funny to change the template and he moderates the site for me: visit my site!
"Thinking of you, wherever you are
We pray for our sorrows to end, and hope that our hearts will blend.
Now I will step forward to realize this wish.
And who knows, starting a new journey may not be so hard…
Or maybe it has already begun.
There are many worlds, but they share the same sky
one sky, one destiny..."
-
Jun 22nd, 2006, 07:48 PM
#6
Lively Member
Re: [2005] Favicon.ico in VB.NET?
http://www.vbforums.com/showthread.p...ght=imagecombo
It was a control from VB6, I guess it didn't get included with the .NET stuff, but according to this post, you can get a customized one that inherits all the properties of the original ComboBox but includes support for images.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|