Webbrowser tip 1 (favorites)

Source: Internet
Author: User
Tags getstream

Reprinted

Ccommand "editmode") has many drawbacks, such as the inability to display the selected text. In addition, some methods do not need to be listed one by one.

What I want to mention here is about mshtml. htmldocument

Reference Microsoft HTML Object Library

Rem # form code #

Dim withevents m_dom as mshtml. htmldocument
Private function m_dom_oncontextmenu () as Boolean
M_dom_oncontextmenu = false
End Function

Private sub webbrowser1_downloadcomplete ()
Set m_dom = webbrowser1.document
End sub

Rem okay, right-click the menu and no more

 

========================================================== ========================================================

Call the control and get it from favorites

Basically, you can get the path of the favorites folder by using specialfolder (6). Then you can use dir to read each directory cyclically, and then the file in Dir, the file name is the name you want to add to favorites. The path can be obtained by yourself based on the Path obtained above.
If you do not need Dir, you can also use the Dir control of VB.
Private type shitemid
CB as long
Abid as byte
End type

Public type itemidlist
Mkid as shitemid
End type
Public Function specialfolder (byref csidl as long) as string
'Locate the favorites folder
Dim R as long
Dim Spath as string
Dim IDL as itemidlist
Const noerror = 0
Const max_length = 260
R = shgetspecialfolderlocation (mdimain. hwnd, csidl, IDL)
If R = noerror then
Spath = space $ (max_length)
R = shgetpathfromidlist (byval IDL. mkid. CB, byval Spath)
If r then
Specialfolder = left $ (Spath, instr (Spath, vbnullchar)-1)
End if
End if
End Function
========================================================== ========================================================== ==============================
Full Screen

Yes, webbrowser is a control. You want it to be full screen, that is, the full screen of the form in which it is located. You can use setwindowlong to cancel the title of the form and call showwindow (findwindow ("shell_traywnd ", ""), 0) Hide tray, that is, the line containing the start line below. use call showwindow (findwindow ("shell_traywnd", ""), 9) to restore. enough details.

Then in form1.windowstate = 2.

========================================================== ========================================================== ====================================
Select the content on the webpage.
Private sub commandementclick ()
'Select some content first
Me. webbrowser1.execwb olecmdid_copy, olecmdexecopt_dodefault
Msgbox clipboard. gettext
End sub

========================================================== ========================================================== ====================================
Use IE to download files
Private declare function dofiledownload lib "shdocvw. dll" (byval lpszfile as string) as long

Private sub commandementclick ()

Dim sdownload as string

Sdownload = strconv (text1.text, vbunicode)
Call dofiledownload (sdownload)

End sub

Private sub form_load ()
Text1.text = "http://www.chat.ru /~ Softdaily/fo-ag162.zip"
Form1.caption = "audiograbber 1.62 full"
Text2.text = "http://www6.50megs.com/audiograbber/demos/cr-ag161.zip"
End sub

========================================================== ========================================================== ======================================

How can I dynamically load and delete the webbrowser control?

Private sub commandementclick ()
Form1.controls. Add "shell. assumer.2", "newweb", form1
With form1! Newweb
. Visible = true
. Width = 10000
. Height = 10000
. Left = 0
. Top = 0
. Navigate2 "www.csdn.net"
End
End sub

Private sub command2_click ()
Controls. Remove form1! Newweb
End sub

Form1.controls. Add "shell. assumer.2", newweb (newweb. Count), form1
With form1! Newweb (newweb. Count)
. Visible = true
. Width = 1000
. Height = 1000
. Left = newweb (newweb. Count-1). Left + newweb (newweb. Count-1). Width
. Top = 0
'. Navigate2 "www.csdn.net"
End
Why did he say "I "?
Form1.controls. Add "shell. assumer.2", newweb (newweb. Count), form1
This row is of error 13 Type mismatch?
PS: I already have a newweb (0) Control in form.

 

First for a webbrowser
Dim I as integer
Private sub addweb_click ()
For I = 1 to 10
Load newweb (I)
Newweb (I). Top = I * 100
Newweb (I). Left = I * 100
Newweb (I). Visible = true
Next I
End sub

Private sub delweb_click ()
For I = 1 to 10
Unload newweb (I)
Next I
End sub

========================================================== ========================================================== ==================================

Save the page as a MHT (MHTML) File
1,

Thank you! Now I will pcwak (ShuJian mad life [MS MVP]) the information provided by the hero, for your reference:
I finally found a method to save the page as a MHT (MHTML) file!
First, you must reference a library in the project:
Library CDO
D:/winnt/system32/cdosys. dll
Microsoft CDO for Windows 2000 Library
Second, you need to support the corresponding stream interface. If you cannot find it at the moment, you can use the newer ado that supports it, as shown in figure
Library ADODB
D:/program files/common files/system/ADO/msado15.dll
Microsoft ActiveX Data Objects 2.5 Library
The Code is as follows, which is very simple (due to the characteristics of the stream, in actual applications, it is not necessary to save the file to the disk as in this example to directly convert it into a string or byte array or something.

In addition, I have not tried how to use the Microsoft CDO for Windows 2000 library in Win98. If you are interested, try and follow the instructions to enrich the content :)

Private sub commandementclick ()
'Reference to Microsoft ActiveX Data Objects 2.5 Library
'Reference to Microsoft CDO for Windows 2000 Library
Dim imsg as new CDO. Message
Dim iconf as new CDO. Configuration
Dim objstream as ADODB. Stream

With imsg
. Createmhtmlbody "http://www.163.com /";,,_
"Domain/username ",_
"Password"
Set objstream =. getstream
Call objstream. savetofile ("F:/test. MHT", adsavecreateoverwrite)
End
End sub

2,

'First Add a reference to ADODB and CDO (Microsoft CDO for Windows 2000 library, corresponding to the file name cdosys. dll)
Private sub commandementclick ()
Dim message as new CDO. Message
Dim outstream as ADODB. Stream
On Error goto myerr1
Call message. createmhtmlbody ("http://www.csdn.net", CDO. cdomhtmlflags. cdosuppressnone ,"","")
Set outstream = message. getstream
Call outstream. savetofile ("C:/test. MHT", ADODB. saveoptionsenum. adsavecreateoverwrite)
Msgbox "complete"

Exit sub
Myerr1:
Set message = nothing
Set outstream = nothing
End sub

========================================================== ========================================================== ======================================

 

How can experts call favorites in the webbrowser control and add favorites to favorites?
Option explicit

Private sub commandementclick ()
Dim objsuh as new shelluihelper
Objsuh. AddFavorite "http://www.csdn.net", "csdn"
Set objsuh = nothing
End sub

========================================================== ========================================================== ======================================

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.