How to call JavaScript Functions using ActiveX Controls

Source: Internet
Author: User

1. Register JS functions with ActiveX:
Add the interface method void registerfunction (BSTR bstrfuncname, idispatch * dispfunc) to ActiveX );
JavasBytesCodeDeclare a function and call the registerfunction interface to register the function with ActiveX for ActiveX to call.
2. Save the registered FunctionActivex uses the ccomdispatchdriver object to save the registered JS function (idispatch interface pointer)
Ccomdispatchdriver m_func1;
Void registerfunction (BSTR bstrfuncname, idispatch * dispfunc)
{
If (bstrfuncname = "1 ")
M_func1 = dispfunc;
}
 
3. Call the registered FunctionActivex uses the ccomdispatchdriver: invoken function to call the registered function.
The following is a call to a JS function that accepts an unsigned integer parameter:
Variant vararg [1];
Vararg [0]. Vt = vt_uint; vararg [0]. uintval = 1;
Try {
M_func1.invoken (dispid) dispid_value, vararg, 1 );
}
Catch (...){}
 
4. NoteThe JS function must be called in ActiveXProgramIn the main thread!

 

from: http://www.cnblogs.com/wxy8/archive/2011/04/06/2006743.html

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.