PythonCOM - How to get (LPDISPATCH) of myself?
markus_wankusGETRIDOFALLCAPS at hotmail.com
Mon Mar 8 05:37:54 CET 2004
I have a Python COM server which supports callbacks for a large CAD
program. It adds menu items and then listens to events - however, I
have a problem (obviously)... I'm a COM idiot - so please expect dumb
There are a bunch of functions that require a pointer to the event
handler, or a pointer to my COM server. Prolem is - it is looking for a
pointer to a Dispatch object - but I have already been dispatched.
Maybe an example will clear things up. One of the functions is as follows:
Status = SldWorks.SetAddinCallbackInfo ( ModuleHandle, AddinCallbacks,
Instance handle of the add-in
Pointer to the object that includes the add-in callback methods
Add-in ID; this is the same Cookie you specified in SwAddin::ConnectToSW
TRUE if successful, FALSE if unsuccessful
What I *want* to do is essentially:
SetAddinCallbackInfo(id(self), self, self.ICookie)
...however - this fails because "self" (my COM server) is not a Pointer
to a Dispatch object.
I can get it to work if I do the following:
SetAddinCallbackInfo(id(self), Dispatch(self._reg_progid_), self.ICookie)
...however this dipatches a new instance of my COM server, losing any
attributes that may have been set since instantiation - thus is useless.
Is there a way to get a pointer to a Dispatch object of yourself?
More information about the Python-list