views:

215

answers:

1

I'm having trouble calling a non IDispatch method in an ActiveX control that I've written.

I have a web page with two separate Active X object both of which I've written. I start by calling a method on the first object which returns an interface pointer to a new COM object that is not co-creatable. I then call a method on this new object passing the second ActiveX object as the argument. Inside this method I call QueryInterface to obtain a private/internal interface pointer on my second ActiveX object. The problem is that the returned pointer from QueryInterface is not a valid pointer to my object, and any attempt to use it crashes.

How can I obtain a interface to my actual object that I can use? My private interface uses structures so it not compatible with IDispatch, and being an internal interface I do not desire to expose it at all in the type library.

+1  A: 

It's a little hard to tell with just a description, but I assume that the method on the first object is returning an IDispatch pointer to the object it creates? The JScript environment will only be able to cope with that.

Also, is your implementation of QueryInterface valid? Does it work for you in non-scripting contexts?

I am still a little unclear on which objects have which interfaces, but if you have an object with an IDispatch-unfriendly interface, perhaps you can build a simple wrapper object to hold it, where the wrapper object has a proper IDispatch interface?

Apologies if I am way off the mark...I haven't wrestled with ActiveX stuff in a few months.

Irwin Coleman
I should have answered this myself earlier. You are in the right with the first part - JavaScript is wrapping my object with it's own object so the object being passed to the second ActiveX control is not my object, but the JS wrapper. The QueryInterface is handled by the JavaScript object and returns the a pointer to the IDispatch interface even thought I queried for something else, rather odd really.
Stephen Nutt