Delphi Process Form instances

Source: Internet
Author: User

mshtml is a COM component of Microsoft. It encapsulates all elements and their attributes in the HTML language and can access all elements of a specified Webpage through the standard interface provided by mshtml. the mshtml object model consists of objects and sets. HTML at the root of the page describes a window that opens the page, including a series of sets and objects. Such as the frames set, history, location, Navigator, document, Vi-sum, and event object. The document object is used to describe the actual webpage in the customer window. It consists of a series of attributes, methods, objects, and sets. the all set contains all the tag elements in the webpage. The main methods and attributes are:
(1) length (length): The number of tag occurrences, the set of tags can be understood as a one-dimensional array starting from 0, and its order is sorted by tag on the webpage.
(2) Tags (TAG ): used to filter the set of given tags, such as Doc. al1.tags (p) returns all the segments marked with P;
(3) item (Project): used to select an element in the set, such as an object. item (0) gets 1st elements of the Set, and object. item (I) obtains the I + 1 element.
In addition, ihtmlelement is a common set object that represents the set marked in a webpage. Through this set object, you can obtain the content marked on the webpage. ihtmlelement has four main attributes:
(1) innertext: text between the start tag and the end tag;
(2) innerhtml:
(3) outertext: Object text;
(4) outerhtml: Object text and HTML.

Procedure tform1.button1click (Sender: tobject );
VaR
DOC: ihtmldocument2;
Input: olevariant;
Userinputelement, pwdinputelement: ihtmlinputelement;
Begin
DOC: descriwebbrowser1.doc ument as ihtmldocument2;
Userinputelement: = (Doc. All. Item (''user'' (the name of the user name control in the webpage), 0) as ihtmlinputelement );
Userinputelement. Value: = edit1.text; (that is, what you want to input to the webpage)
Pwdinputelement: = (Doc. All. Item ('Password', 0) as ihtmlinputelement );
Pwdinputelement. Value: = edit2.text;
Input: = Doc. All. Item (''submit '', 0 );
Input. Click;
End;

When the data submission button does not have the name attribute, use the following method:

Procedure tform1.button1click (Sender: tobject );
VaR
DOC: ihtmldocument2;
Form: ithmlformelement;
Userinputelement, pwdinputelement: ihtmlinputelement;
Begin
DOC: descriwebbrowser1.doc ument as ihtmldocument2;
Userinputelement: = (Doc. All. Item (''user'' (the name of the user name control in the webpage), 0) as ihtmlinputelement );
Userinputelement. Value: = edit1.text; (that is, what you want to input to the webpage)
Pwdinputelement: = (Doc. All. Item ('Password', 0) as ihtmlinputelement );
Pwdinputelement: = edit2.text;
Form: = (Doc. All. Item (''login _ form'', 0) as ihtmlformelement): form. Submit;
End;

The logon button is usually the default carriage return button on the webpage.CodeTo replace the previous button.
 

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.