Alex Denham wrote:
I've had a look at the example and i can't quite pick out what's being
done differently other than pythoncom.WrapObject() is being called within
a class and it's being called on the > class it's in?
Or is it something to do with the arguments passed to wrap object?

Thanks for the help.
Alex

The class has to explicitely inherit from a policy class
(win32com.server.policy.DesignatedWrapPolicy), and
it has to have an __init__ method that calls _wrap_.
Also, an instance of the class is passed to WrapObject
rather than the class itself.

This is snipped from a working example:

class IDropTarget(win32com.server.policy.DesignatedWrapPolicy):
   _com_interfaces_=[pythoncom.IID_IDropTarget]
   _public_methods_=["DragEnter","DragOver","DragLeave","Drop"]

   def __init__(self):
      self._wrap_(self)

   def DragEnter(self, DataObject, KeyState, pt, Effect):
       print "DragEnter"
       print DataObject, KeyState, pt, Effect
   def DragOver(self, KeyState, pt, Effect):
       print "DragOver"
       print KeyState, pt, Effect
   def DragLeave(self):
       print "DragLeave"
   def Drop(self, DataObject, KeyState, pt, Effect):
       print "Drop"
       print DataObject, KeyState, pt, Effect

dt=IDropTarget()
IDT=pythoncom.WrapObject(dt, pythoncom.IID_IDropTarget, pythoncom.IID_IDropTarget)

pythoncom.RegisterDragDrop(hwnd, IDT)

          Roger

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to