WebBrowser Tips (Collection)

zhaozj2021-02-11  214

Reprint

Seeing a lot of questions about the WebBrowser control prohibited right-click, there are many ways to reply, where there is a webbrowser extended COM server object (WBCustomizer.dll) that Microsoft provides WebBrowser.dll, but this method uses WebBrowser editing web pages (WebBrowser1.Document. There are many drawbacks when Execcommand "EditMode"), such as the selected text, etc. In addition, there are no listings.

I would like to mention this about mshtml.htmldocument

Quote Microsoft HTML Object Library

REM # Form Code #

DIM WITHEVENTS M_DOM AS MSHTML.HTMLDocument Private Function M_DOM_ONCONTEXTMENU () AS Boolean M_Dom_oncontextMenu = FalseEnd Function

Private sub webbrowser1_download mobilecomplete () set m_dom = webbrowser1.document end SUB

REM is ok, right-click menu is not

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

Control calls and get the favorites

Basically use SpecialFolder (6) to get the favorite path, then you can use DIR to read into each directory, then the file inside DIR, the name of the file is the name you want, the path can be based on The path you get it goes. If you don't have DIR can also use VB's DIR control .private type shithemid cb as long abid as byteend type

Public Type ITEMIDLIST mkid As SHITEMIDEnd TypePublic 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 SPECIAL = Left $ (Spath, Instr (Spath, VBnullchar) - 1) End If end ifend function =============================================== ============================================================================================================================================================================================================= === Full-screen, webbrowser life is a control, you want it full screen, you want it to be full screen, you can use setWindowlong to cancel the form of the form with Call showWindow ("shell_traywnd", "" 0) Hide TRAY is the following lines that contain the beginning. Use Call showWindow ("shell_trayWnd", 9) to recover. It is enough.

Then in Form1.WindowState = 2 is OK.

============================================================================================================================================================================================================= ============================================================================================================================================================================================================= ========== Select the content on the web page. Private sub fascist1_click () 'Please select some of the content me.webbrowser1.execwb olecMDID_COPY, OLECMDEXECOPT_DODEFAULTMSGBOX CLIPBOARD.GETTEXTEND SUB =========================== ============================================================================================================================================================================================================= ================================= With IE to download the file private declare function Dofiledownload Lib "shdocvw.dll" LPSZFILE AS STRING AS Long

Private Sub Command1_Click () Dim SDownload = String (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

============================================================================================================================================================================================================= ============================================================================================================================================================================================================= ============ I want to dynamically load and delete the webbrowser control how should I do?

Private sub fascist1_click () form1.controls.add "shell.explorer.2", "newweb", form1 with form1! Newweb .visible = true .width = 10000.height = 10000 .left = 0 .top = 0 .navigate2 Www.9cbs.net "End Wirth Sub

Private submmand2_click () controls.remove form1! Newwebend Sub

Form1.controls.add "shell.explorer.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.9cbs.net" end with why he said that I spent Form1.Controls.Add "shell.explorer.2", NewWeb (newWeb.count), FORM1 This line error 13 type does not match? PS: I already have a newweb (0) control in Form.

First, a WebBrowserdim I as IntegerPrivate 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 IEND SUB

Private sub Delweb_Click () for i = 1 to 10 unload newWeb (i) Next Ind Sub =============================== ============================================================================================================================================================================================================= ============================

One saved the page as MHT (ie MHTML) file 1,

Thank you for a few heroes! I now put the information provided by PCWAK (Sword Music [MS MVP]) for your reference: I finally found a way to save the page as a MHT (ie MHTML) file! First, in the project You must reference a library: library cdod: /winnt/system32/cdosys.dllmicrosoft CDO for Windows 2000 Library Second, you need the support of the stream corresponding to the interface, if you can't find the newer ADO to support this, Such as library adodbd: / program files / compon files / system files / msado15.dllmicrosoft ActiveX Data Objects 2.5 library code is simple (simultaneous due to the characteristics of the stream), there is no need to save files like this example in this example. To the disk, you can directly convert to a string or byte array what is processed.

Also, for Microsoft CDO for Windows 2000 Library, how to use it in Win98 hasn't tried it, interested friends can try and follow the post to improve their content :)

Private Sub Command1_Click () 'Reference to Microsoft ActiveX Data Objects 2.5 Library' Reference to Microsoft CDO for Windows 2000 LibraryDim iMsg As New CDO.MessageDim iConf As New CDO.ConfigurationDim objStream As ADODB.Stream

WITH IMSG.CREATEMHTMLBODY "http://www.163.com/"; _ "domain / username", _ "password" set objstream = .GetStreamCall Objstream.savetofile ("f: /test.mht", AdsaveCreateoverWrite) End welhend Sub

2,

'First of all join Dim message As New CDO.message Dim Outstream As ADODB.Stream On Error GoTo myerr1 Call message to ADODB and CDO (Microsoft CDO for Windows 2000 Library, the corresponding file named CDOSYS.dll) references Private Sub Command1_Click (). CreateMHTMLBody ( "http://www.9cbs.net", CDO.CdoMHTMLFlags.cdoSuppressNone, "", "") Set outstream = message.GetStream Call Outstream.SaveToFile ( "c: /test.mht", ADODB.SaveOptionsEnum. AdsaveCreateOverWrite) msgbox "Complete" exit submyerr1: set message = nothing set outstream = nothingnd sub ================================ ============================================================================================================================================================================================================= ================================

How do experts call your favorites in the WebBrowser control and add a collection of Option Explicit in your favorites

Private Sub Command1_Click () Dim objsuh as new shelluihelper objsuh.addfavorite "http://www.9cbs.net", "9cbs" set objsuh = nothingend subjsuh = Nothingend Sub

转载请注明原文地址:https://www.9cbs.com/read-5994.html

New Post(0)