开发者

Why doesn't IE listen to ActiveX events?

I put ActiveX control onto HTML page with longrun method that should fire events to be processed by IE.

They don't fire because m_vec.GetSize() == 0, it means IE doesn't connect to my ActiveX.

Site is localhost, it's in Trusted sites and security level is set to minimum.

Html

 <object id="myObj" name="myObj" ...&开发者_如何学Pythongt;                    
 </object>   

   <script type="text/javascript" for="myObj" event="CallbackMethod(...)" language="javascript">
        alert("hello!");
    </script>

IDL

[uuid(...), dual]
interface _IBasicEvents : IDispatch
{   
    [id(1)] HRESULT CallbackMethod(...);
};

[uuid(...)] 
coclass MyService
{       
    [default] interface IBasicInterface;        
    [default, source] dispinterface _IBasicEvents;
};

С++ inheritance list:

class ATL_NO_VTABLE CMyService :
    public CComObjectRootEx<CComSingleThreadModel>, 
    public CComControl<CMyService>, 
    public CComCoClass<CMyService, &CLSID_MyService>,
    public IConnectionPointContainerImpl<CMyService>,       
    public IObjectWithSiteImpl<CMyService>,     
    public IPersistPropertyBagImpl<CMyService>, 
    public IObjectSafetyImpl<CMyService, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
    public IOleInPlaceObjectWindowlessImpl<CMyService>,
    public IOleObjectImpl<CMyService>,
    public IDispatchImpl<IBasicInterface, ...>,
    public CProxy_IScannerServiceEvents<CMyService>

COM_MAP

COM_INTERFACE_ENTRY(IBasicInterface)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IObjectWithSite)    
COM_INTERFACE_ENTRY(IOleObject) 
COM_INTERFACE_ENTRY(IObjectSafety)  
COM_INTERFACE_ENTRY(IPersistPropertyBag)    

CONNECTION_POINT_MAP

CONNECTION_POINT_ENTRY(__uuidof(_IBasicEvents))

CATEGORY_MAP

IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)

What is wrong here ? Why IE doesn't connect to my connection point interface?

Temporary Solution

I abandoned games with <script for event> and start to pass javascript callback function as method parameter (type IDispatch*)


[uuid(...), dual] interface _IBasicEvents : IDispatch

[default, source] dispinterface _IBasicEvents;

AFAIK IDL coclass should reference event interface, as you do above, but your _IBasicEvents is not defined as dispainterface. Instead it is a real interface, which is not correct. There should be:

[ ... ] dispinterface _IBasicEvents { methods: ... };

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜