// 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.