[python-win32] DispatchWithEvents

Mark Hammond mhammond at skippinet.com.au
Tue Sep 7 01:45:15 CEST 2004


> On the server side of DispatchWithEvents, does the VC++ code that
> implements an automation server must also implement
> connectionpoints for
>   DispatchWithEvents?
>
> In other words, DispatchWithEvents is expecting
> connectionpoints on the
> server?  Or is there some other event mechanism?

It uses connection-points.  Check out the __init__ code in classes generated
by makepy for event classes:

import win32com.server.util
from win32com.server.policy import EventHandlerPolicy
cpc=oobj._oleobj_.QueryInterface(pythoncom.IID_IConnectionPointContainer)
cp=cpc.FindConnectionPoint(self.CLSID_Sink)
cookie=cp.Advise(win32com.server.util.wrap(self,
usePolicy=EventHandlerPolicy))
self._olecp,self._olecp_cookie = cp,cookie

This is just a fairly standard connection-point dance, but with a few things
to trick the pythoncom framework into doing the right thing.

Mark.



More information about the Python-win32 mailing list