Handling Events Fired Using the ActiveX Control Property in HTML / Javascript

The following HTML object represents an ActiveX control that has a property called SubSystemA:

<object id="MainObject" CLASSID="CLSID:2C327457-D12F-4FC4-BFC2-D7C029003D07" width="0px" height="0px" > <embed name="MainObject"></embed> </object> 

SubSystemA is a COM object that implements some interface with methods, properties, and events. SubSystemA methods and properties can easily be called from Javascript, but since SubSystemA is a MainObject property, I'm not sure how to attach an event handler to SubSystemA events.

I know two ways to handle events triggered by MainObject:

 <script type="text/javascript"> function MainObject::SomeMainEvent(arg1, arg2) { // Event handling logic } </script> 

and

 <script type="text/javascript" for="MainObject" event="SomeMainEvent(arg1, arg2)"> // Event handling logic </script> 

But how would I handle the event for MainObject.SubSystemA?

+4
source share
2 answers

I found that the following works:

 <object id="MainObject" CLASSID="CLSID:2C327457-D12F-4FC4-BFC2-D7C029003D07" width="0px" height="0px" > <embed name="MainObject"></embed> </object> <script type="text/javascript"> function MainObject.SubSystemA::SomeSubSystemEvent(arg1) { // Event handling logic } </script> 

and I'm currently looking for a way to adapt the <script for = "..." event = "..."> syntax, as it seems to allow later binding where the working syntax doesn't work.

+1
source

The easiest way I've found to create events in a subobject that allows a javascript-compliant implementation of events is to implement attachEvent and detachEvent myself; just save the IDispatch * to the function that was passed, and then go through them and call Invoke with DISPID = 0 on each of them.

For MainObject itself, you probably have to use connection points that work differently.

FireBreath abstracts all this for both IE and Firefox, including the creation of separate COM objects. Maybe worth a look

+1
source

All Articles