PythonCOM - How to get (LPDISPATCH) of myself?
Markus Wankus
markus_wankusGETRIDOFALLCAPS at hotmail.com
Sun Mar 7 23:37:54 EST 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
questions.
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,
Cookie )
Input:
(long) ModuleHandle
Instance handle of the add-in
Input:
(LPDISPATCH) AddinCallbacks
Pointer to the object that includes the add-in callback methods
Input:
(long) Cookie
Add-in ID; this is the same Cookie you specified in SwAddin::ConnectToSW
Output:
(VARIANT_BOOL) Status
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?
Thanks,
Mark.
More information about the Python-list
mailing list