VB Operation WebBrowser Access MSHTML Member Little Experience

zhaozj2021-02-16  43

VB Handling WebBrowser Access MSHTML is limited by VC , but the problem is not large for most applications, and the implementation process is also very simple.

I. Using WebBroswer Controls in VB 1. Use Microsoft Internet Controls to use Microsoft Internet Controls to make browsers, but far from the webbrowser can be able to do. Some features that VB can implement are as follows:> Take the WebBrowser control Implementation browsing features> Automation IE > Capture IE Events> Access DHTML Object Model But VB cannot use advanced palm interface to implement some features such as turning off the Context Menu and control downloading. Knowledge for IE programming with VB can refer to Microsoft Book << Microsoft Internet Exploer 5 programming ( Programmning Internet Explorer 5) >> The corresponding part.

2. Calling WebBrowser's ExecwB methods can implement additional features such as CUT, PASTE, and Saves, etc., which are included in the OLEMDID enumeration table, which can be seen in the object browser. This way we can make WebBrowser have some editing features, such as : WebBrowser1.execwb Olecmdid_Paste, Olecmdexecopt_dodefault You can touch the contents of the HTML format into WebBroser, which can easily implement an HTML clip tool, copy characters, and reserve formats, NOTEPADs.

II. Visit the MSHTML member

1. Use VB to access the DHTML model to implement the operation of the HTML element is very easy. Reference MICSoft HTML Object Library can be used to see the included class and its property method in the object browser. The mainly included HTML and IHTML are class The class prefixed, these classes provide definitions and interfaces for HTML, DHTML, and script (VBScript, JavaScript) objects. In VB we can use these classes to create object instances for accessing web elements. And programming and write web page scripts As simple and similar, so you can use VBScript and JavaScript information for reference (I learned DHTML when learning VB), for example: Microsoft Book << Dynamic hypercraft logo language from getting started (Inside Dynamic HTML) ) >> (a very bad book for translation!). If you master VC and MFC, MSDN is natural is also a good place, there is rich information about MSHTML (although we can't move in VB, we can test VB in many Feasibility.)

2.MSHTML class [MICSoft HTML Object Library] Access MSHTML To reference the MSHTML component library. Before IE5, this library is included in the mshtml.dll, which is transferred to the IE5. This type of library is transferred to MSHTML.TLB. The reason, maybe not see the MICSoft HTML Object Library in the reference list, but you can type the type library file name to add a reference in the File dialog box.

3. An example: When using a search engine (such as MSN) to search your English webpage, you want the keyword to highlight or increase the display in the collected entry. I let webbrowser navigate to the search page, then give all the keywords plus it. , additional hyperlinks on the webpage into a list box. Find the keyword Use IHTMLTextRange, which is used to access the text on the webpage.

Part: Microsoft Internet Controls Quote: MICSoft HTML Object Library --- See "MSHTML Class" control: webbrowser1; list1; label1; command1 attribute: command1.caption = "find"

CODE:

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

New Post(0)