Home > Software engineering >  Vb to save the page icon
Vb to save the page icon

Time:10-09


Private Sub Web1_DocumentComplete (ByVal pDisp As Object, the URL As the Variant)
'stay after the page load, and then perform the following statement:

Dim nPath As String, E, nRange

NPath=App. Path & amp; "\ " web icon

Web1. Silent=True 'close interaction to ban script errors
Dim s As String
For Each E In Web1. Document. All

S=e. agName
If e. agName="IMG" Then

The Set nRange=Web1. Document. Body. CreateControlRange ()

NRange. Add E
The Clipboard. The Clear
NRange. ExecCommand "Copy" Copy to clipboard

SavePicture Clipboard. GetData nPath & amp; "The favicon. BMP" '
saved to the hard disk
End the If

Next
End Sub

Private Sub Form_Load ()
Web1. Navigate2 "http://google.com/favicon.ico"
End Sub

Want to use this method to get the page icon, when debugging, display SavePicture Clipboard. GetData, nPath & amp; "The favicon. BMP" '
saved to the hard diskError 380, an invalid attribute value,
If this method is not used, can use what method according to the web page url to get the icon?

CodePudding user response:

Don't need to use inet control directly download the favicon. Ico is ok,

CodePudding user response:

Can look for local cache file directly and copy to a custom directory,,,,

CodePudding user response:

reference 1st floor caozhy response:
, it is not necessary to use directly download the favicon inet control. Ico,

Can provide a reference code, find the code on the net, download after not to. Ico format, even change the suffix also cannot use,
I want to use webborwser download the reason for this is that I want to use webbrowser in application, open a url will display the corresponding icon,

CodePudding user response:

Can directly show online pictures, or use the XMLHTTP

CodePudding user response:




reference 1st floor caozhy response:
, it is not necessary to use directly download the favicon inet control. Ico,

Try to download the favicon inet. Ico,
Private Sub Command1_Click ()
Dim (b) As Byte
Dim strURL As String
StrURL="http://www.baidu.com/favicon.ico"
(b)=Inet2. OpenURL (strURL, icByteArray)
The Open c: \ "logo. Ico" For Binary Access Write As # 1
Put # 1, and (b)
Close # 1
Picture1. Picture=LoadPicture (" c: \ logo. Ico ")
End Sub
But some problems:
When strURL="http://www.google.com/favicon.ico", in the local directory is can see download the pictures, but into the picture prompt invalid images, when strURL="http://www.baidu.com/favicon.ico" or strURL="http://www.weibo.com/favicon.ico", can be loaded into the picture, what reason is this??

CodePudding user response:

Can someone help me have a look at it?

CodePudding user response:

The problem of VB application ICON attribute
A lot of friends in the use of VB programming, find the ico icon found on the Internet cannot be used in VB, you will be prompted error

It's not a question of VB, but the image itself, a series of pictures, VB requirements ico must contain 16 * 16256 colors icon, otherwise will prompt wrong,
You can use IconCool Editor localization version to solve, to load the picture first, after adjusting for 16 * 16256 color, can,
Suggest to make double format, 16 and 32 * 32 * 16256 color, 32 have better color depth, but I haven't find a way,

From baidu,

No problem, you downloaded but vb show,,,
  • Related