MFC ActiveX OCX JavaScript mutual access problem, thread callback Javascript

Source: Internet
Author: User
// Better tutorial OCX requires administrator permission to register in win7. In this case, run cmd as the administrator and run regsvr32 to register. Very troublesome Try to use NSIs as the installation package and use regdll to register OCX.

OCX and externalProgramThe interaction is mainly through the provision of method attributes + events

Method attributes can be provided to JS calls, events can inject <Object ID = "XXX"> </Object> <script language = "JavaScript" for = "XX" event = "eventfunction (x) "> Alert (x); </SCRIPT> Or document. getelementbyidx_x (XX). attachevent ("eventfunction", function (x, y ){
Alert (X );
}); Both functions can be selected in the Class View. Xxxctrl, right-click Add, and a method property event will appear.Follow the wizard. It mainly records that if OCX creates a thread and wants to callback JS through the event, problems will occur. At this time, the solution is to use postmessage (wm_threadfireevent, (wparam) null, (lparam) null); the following can be understood //------------------------- Sample: Firing Events From A Second Thread

---------------------------------------------------------------------
The Information In This Article Applies To:

- Microsoft Visual C ++, 32-bit Edition Versions 4.0, 4.1, 4.2
---------------------------------------------------------------------

Summary
========

MFC Based ActiveX Controls Typically Fire Their Events From The Same Thread
That Implements The Sink Interface Of The Container That The Events Are
Being Fired To.

Sometimes, It Is Desirable To Start A Second Thread In An ActiveX Control
Which Will Fire Events To The Container. Since MFC ActiveX Controls
Use The Apartment Threading Model, Special Consideration Must Be Taken
Into Account When Firing Events From A Secondary Thread.
Related Article

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.