JS calls Delphi to write the OCX control

Source: Internet
Author: User

Original: http://www.mamicode.com/info-detail-471283.html

First, using Delphi XE2 to write the OCX control

    • Generate OCX Project:

1, File-new-other, in the New Items dialog box, select the Delphi projects-activex-activex Library

2, File-new-other, in the New Items dialog box select Delphi Projects-activex-activex Control, here to seal the Delphi Tstringgrid control, so choose ActiveX Control, and other settings can be set by dialog box.

    • New properties, Methods for OCX

View-type library pops up a form with an extension of Ridl

A Cells property and a Methodtest method are defined here. Why are there two cells? That's because a read, a write, can be seen by the invoke kind property on the right side of the attributes page. There is also a property type that is the property. You can also set parameters via the Parameters page, after the settings are complete such as:

Get Parameters:

Put parameters:

Methodtest Parameters:

You can then press the Refresh button on the Ridl form to generate the method body:

Second, JS call

Code:

<HTML>
<HEAD>
<title>myactivex-methods, Properties, and events</title>
<script language= "JavaScript" >

function PropertyTest ()
{
Myactivex1.cells (2,2) = Stringinput.value
}

function Jsmethodtest ()
{
Alert (Myactivex1.methodtest ())
}
</SCRIPT>

<!--capturing the double-click event of the OCX control--
<script type= "Text/javascript" for= "MyActiveX1" event= "OnDblClick" >
<!--Insert script commands--
Alert ("The event has been captured! ");
</SCRIPT>

</HEAD>
<BODY>
<center>
Myactivex-methods, Properties, and Events Example
<p></p>
<object id= "MyActiveX1" width=500 height=200
Classid= "clsid:e61826b4-18b3-4e6d-aed6-78361961d29c" >
</OBJECT>
<p></p>
Input Parameter: <input TYPE = "text" name= "Stringinput" value= "" >
<input type= "button" Name= "Submit1"
Value= "Properties" onclick= "PropertyTest ()" >
<p></p>
<input type= "button" Name= "Submit2"
Value= "Methods" onclick= "Jsmethodtest ()" >

</center>
</BODY>
</HTML>

:

An example of the use of the OCX control properties, methods, and events has been completed.

JS calls Delphi to write the OCX control

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.