This Question is Answered

2 "helpful" answers available (2 pts)
6 Replies Last post: Aug 18, 2008 4:12 PM by Manuel Crespo  
Manuel Crespo   12 posts since
Apr 24, 2006
Currently Being Moderated

Aug 12, 2008 1:54 PM

Problem with Events

 

Hello,

 

 

I'm new with ComfyJ. I'm just trying to integrate a very simple ActiveX I have done just to learn how to use it before doing the real work, but I'm having problems or doubts with events.

 

 

I'm trying to follow the ComfyJ programers guide the chapter 4.7 Registering Callbacks for Generated COM Components (COM Events Handling). So, this is teh way I'm trying to integrate my OCX:

 

 

  private void createOleObject()

    {

        container.createObject(CLASSID);

        manoloActiveForm = new IManoloActiveFormImpl(_container.getOleObject());

 

        IConnectionPointContainer connectionPointContainer = new IConnectionPointContainerImpl(_container.getOleObject());

        IID iid = new IID(IManoloActiveForm.INTERFACE_IDENTIFIER);

        IConnectionPoint connectionPoint = connectionPointContainer.findConnectionPoint(iid);

 

        ManoloActiveFormEventsHandler handler = new ManoloActiveFormEventsHandler();

        connectionPoint.advise(handler);

    }

 

 

 

 

 

 

But I get this error:

 

 

com.jniwrapper.win32.com.ComException: COM object method returns error code: 0x80040200; PERPROP_E_NOPAGEAVAILABLE

at com.jniwrapper.win32.com.impl.IUnknownImpl.invokeStandardVirtualMethod(SourceFile:681)

at com.jniwrapper.win32.ole.impl.IConnectionPointContainerImpl.findConnectionPoint(SourceFile:78)

at pruebamanolo.mainproject.Frame3.createOleObject(Frame3.java:93)

 

 

Line 93 is IConnectionPoint connectionPoint = connectionPointContainer.findConnectionPoint(iid);

 

 

What am I doing wrong?. Is there any other example that shows how integrate events?.

 

 

 

 

Thanks

Manuel Crespo

 

 

 

 

 

 

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
1. Aug 12, 2008 5:36 PM in response to: Manuel Crespo
Re: Problem with Events

Hi Manuel,

 

Such COM exception (PERPROP_E_NOPAGEAVAILABLE) indicates that a COM object does not have an appropriate connection point for the IID that you have specified for findConnectionPoint() method. Please make sure that that IID is correct and/or COM object itself provides the ability to add the event subscribers.

 

-Serge

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
3. Aug 13, 2008 10:56 PM in response to: Manuel Crespo
Re: Problem with Events

Hi Manuel,

 

It looks like the the created VTBL is incorrect. Can you please send us an example so we can reproduce and fix the issue?

 

-Serge

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
5. Aug 14, 2008 5:50 PM in response to: Manuel Crespo
Re: Problem with Events

Hi Manuel,

 

Unfortunately I was not able to send this message on your email address somehow (probably due to some email issues), so I am posting the replay on the forum.

 

Thanks for the sample application. I have investigated it and found the cause of the problem. It was in the following code:

IClassFactoryServer server = new IClassFactoryServer(IManoloActiveFormEventsServer.class);
//server.registerInterface(IManoloActiveFormEventsServer.class, new IManoloActiveFormVTBL(server)); <- this is incorrect
server.registerInterface(IManoloActiveFormEvents.class, new IDispatchVTBL(server)); // register the required COM interface
server.setDefaultInterface(IDispatch.class);

 

Actually the problem was in using incorrect interface and incorrect VTBL class in the registerInterface() method. In fact IManoloActiveFormEventsServer class implements IManoloActiveFormEvents COM interface and this interface should be registered. Also, itÂ’s incorrect to use the VTBL of another COM class (IManoloActiveFormVTBL) for it.

 

In case you register a COM interface which does not have an appropriate VTBL (if itÂ’s an dispinterface), then IDispatchVBTL class should be used by default.

 

I have fixed this issue, modified the code a little bit in several places and it started working correctly. The modified sources are attached.

 

Also, supposing that you are already using ComfyJ 2.4 build #902, please use the attached comfyj-generator-2.4.902.jar file instead of previous one. This updated JAR produces more correct Java wrappers.

 

Please try the updated application and let me know the results.

 

-Serge

More Like This

  • Retrieving data ...