简体   繁体   English

使用网页上另一个ActiveX控件中的ActiveX控件

[英]Using an ActiveX control from another ActiveX control on a web page

I'm having trouble calling a non IDispatch method in an ActiveX control that I've written. 我在编写的ActiveX控件中调用非IDispatch方法时遇到麻烦。

I have a web page with two separate Active X object both of which I've written. 我有一个网页,其中包含两个我分别编写的Active X对象。 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. 我首先在第一个对象上调用一个方法,该方法返回一个接口指针,该接口指针指向一个不能共同创建的新COM对象。 I then call a method on this new object passing the second ActiveX object as the argument. 然后,我在此新对象上调用方法,并将第二个ActiveX对象作为参数传递。 Inside this method I call QueryInterface to obtain a private/internal interface pointer on my second ActiveX object. 在此方法内部,我调用QueryInterface以在第二个ActiveX对象上获取私有/内部接口指针。 The problem is that the returned pointer from QueryInterface is not a valid pointer to my object, and any attempt to use it crashes. 问题是从QueryInterface返回的指针不是指向我的对象的有效指针,并且任何使用它的尝试都将崩溃。

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. 我的私有接口使用结构,因此它与IDispatch不兼容,并且作为内部接口,我根本不想在类型库中公开它。

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? 仅通过描述就很难说清楚,但是我假设第一个对象上的方法正在返回IDispatch指针指向它创建的对象? The JScript environment will only be able to cope with that. JScript环境将只能解决这个问题。

Also, is your implementation of QueryInterface valid? 另外,您对QueryInterface的实现是否有效? 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? 我仍然不清楚哪些对象具有哪些接口,但是如果您的对象具有IDispatch不友好的接口,也许可以构建一个简单的包装对象来容纳它,而包装对象具有正确的IDispatch接口呢?

Apologies if I am way off the mark...I haven't wrestled with ActiveX stuff in a few months. 不好意思,我很抱歉...几个月来我没有与ActiveX搏斗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM