Creating event objects

John Pompeii <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <LISTSERV%[email protected]>
If I may impose again for some help....

I'm trying to invoke a method that's intended to take an object as an event
handler.  The method (of a class called MbtQuote) is:

public void AdviseSymbol(Object[] pNotify,String bstrSymbol,int
lServiceFlags) throws COMException

the first parameter is documented to take an instance of "IMbtQuotesNotify"

The class IMbtQuotesNotify was generated as a class derived from COMPtr
(not DispatchPtr as most of the others are) and has no generated
constructor.  If I simply new up one these and pass it to the AdviseSymbol
method, I get a fatal exception the the following console output:

java.lang.Error: Type cannot be marshalled to variant: class
mbt.IMbtQuotesNotify
 at org.jawin.Variant.marshalIn(Variant.java:106)
 at org.jawin.Variant.marshalInArray(Variant.java:300)
 at org.jawin.Variant.marshalIn(Variant.java:68)
 at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:467)
 at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:433)
 at mbt.IMbtQuotes.AdviseSymbol(IMbtQuotes.java:147)
 at xqqq.TestMBTConnect.main(TestMBTConnect.java:79)

here's the code:

   IMbtQuotes quotes = commMgr.getQuotes();
   Object[] ObjectParam = new Object[1];
   ObjectParam[0] = new IMbtQuotesNotify();
   quotes.AdviseSymbol(ObjectParam, "QQQ",
                       enumQuoteServiceFlags.qsfLevelOne);

I assume the problem here is that the instance I'm passing it does not
represent an existing COM object instance.  I tried to steal the code from
the constructor of DispatchPtr but I got an exception complaining that the
class was not registered.

What do I need to do property create the object that this method wants?

Thanks again for the help!

--john
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.