ActiveX Automation Events

Forums for specific tips, techniques and example code
concord
Posts: 48
Joined: Wed Mar 23, 2011 2:07 pm

ActiveX Automation Events

Postby concord » Thu Mar 15, 2012 3:41 pm

I use a handful of ActiveX's but have never attempted to receive an event for any of them.

The Jade docs have pretty clear instructions on how to do this....

1. Create a Reference, type = IDispatch subclass:
app.email_events (Class:IEmail_Events)

2. Add logic to the methods (events) that display for the referenced class:
app.email_events:email_events_connected ();
write 'Here is your event';


3. Register interest in your event:
create oSmtp transient;
oSmtp.createAutomationObject();
oSmtp.beginNotifyAutomationEvent(app, 'email_events');


All seems too easy. I'm expecting an instance of the IEmail_Events IDispatch class to be created at some stage. Then when I engage the oSmtp in the correct fashion for the "connected" event to fire and see my write statement.

If I understand this correctly, the automation object will trigger an event, Jade will pick up on it and action it by sending it to the receiver (in this case app), more specifically Jade will locate the referenced object "app.email_events" and call the method "email_events_connected ()" on this object.

It's just not happening.
There is no instance of IEmail_Events instances being created at all. The app.email_event stays empty, and obviously I see no write statement.

I've played around with the parameters... oSmtp.beginNotifyAutomationEvent(app, 'email_events');... and feel confident I have these correct. It compiles and runs.

Can anyone see where I'm going wrong?

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: ActiveX Automation Events

Postby murray » Thu Mar 15, 2012 8:07 pm

Could it be due to the 'app' object being a transient object that is only visible to the local process? I am not familiar with the scope requirements of the ActiveX event - perhaps it requires a persistent object as receiver that is visible to other processes? Using 'app' as a receiver will only work for events generated within the local process. If you are not sure of this you could try switching from using 'app' as the receiver to using 'global', which is a persistent object and will be visible to all processes.
Murray (N.Z.)

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: ActiveX Automation Events

Postby ghosttie » Fri Mar 16, 2012 3:31 am

We use ActiveX events, and I can confirm that you don't need to manually create an instance of the IDispatch class. Presumably it only needs to exist as a property of the receiver so that there is somewhere for JADE to put the methods.

The one thing that I noticed might be different in your system than ours is that we have the ActiveX object as a property of the receiver as well as the IDispatch - from the code fragment you shared it looked like maybe you were just creating the ActiveX object using a variable. I don't know why this would make a difference but it's worth a shot.
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

concord
Posts: 48
Joined: Wed Mar 23, 2011 2:07 pm

Re: ActiveX Automation Events

Postby concord » Fri Mar 16, 2012 7:44 am

2 good suggestions, thanks guys.

When I implement this properly I'll create a special class to manage the job, It will still be a simple transient object but will hold a reference to the automation object and receive the notification (rather than app).

I wouldn't expect to need a persistent object but flicking my test over to global is easy enough so worth ruling out.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 0 guests