| Store | Cart

PythonCOM - How to get (LPDISPATCH) of myself?

From: Markus Wankus <mark...@hotmail.com>
Sun, 07 Mar 2004 23:37:54 -0500
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, 
Cookie )

  (long) ModuleHandle
  Instance handle of the add-in

  (LPDISPATCH) AddinCallbacks
  Pointer to the object that includes the add-in callback methods

  (long) Cookie
  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?


Recent Messages in this Thread
Markus Wankus Mar 08, 2004 04:37 am
Markus Wankus Mar 09, 2004 03:32 am
Markus Wankus Mar 11, 2004 04:37 am
Messages in this thread