Please Help: COM Events

Ben Shapiro bshapiro at funnygarbage.com
Tue Feb 13 16:03:04 EST 2001


Hi all
I am having a problem with COM events.
I am using the JabberCOM library.  This library contains a bunch of classes
such as JabberSession and JabberMsg.
I create the object with:   JabberCtl =
win32com.client.DispatchWithEvents('JabberCOM.JabberSession',JabberEvts)
the JabberEvts class is registered to handle events for this object....

The problem is this.... in the JabberEvts Class i have the following method
that gets triggered every time a message arrives:
def OnMessage(self, Msg, Tag):
        print "I made it this far ---" #---this works
        print Msg.MsgType #--- never executes

In this method, Msg is an object of type JabberMsg
when i do a print Msg, python reports that it is an IDispatch

Seems to me that when the event handler is called, the argument passed in
loses it's type as a JabberMsg and becomes a generic Dispatch object
so i can't call properties or methods on it.. Is there any way to cast the
argument back to a JabberMsg object?

thx for any help

Ben





More information about the Python-list mailing list