<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><div style="text-align: left;">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?<br>Or is it something to do with the arguments passed to wrap object?<br><br>Thanks for the help.<br>Alex<br></div><br><hr id="stopSpelling">&gt; From: rwupole@msn.com<br>&gt; To: python-win32@python.org<br>&gt; Date: Thu, 24 Apr 2008 17:25:03 -0400<br>&gt; Subject: [python-win32]  Creating python com objects<br>&gt; <br>&gt; <br>&gt; Tim Golden wrote:<br>&gt; &gt; Alex Denham wrote:<br>&gt; &gt;&gt;       Parameters<br>&gt; &gt;&gt; <br>&gt; &gt;&gt; /pDataObj/ : *PyIDataObject **<br>&gt; &gt;&gt;  <br>&gt; &gt;&gt; How do i link the IDataObject to the IDragTarget?<br>&gt; &gt; <br>&gt; &gt; I don't know that you can, if you're asking: how do I<br>&gt; &gt; find out where this is coming from?. I think the drag-drop<br>&gt; &gt; technique is endpoint-agnostic. (A high-sounding phrase I've<br>&gt; &gt; just invented).<br>&gt; <br>&gt; Don't forget to trademark it !<br>&gt; <br>&gt; &gt; The most you can do is get hold of the data.<br>&gt; &gt; Again, I think.<br>&gt; <br>&gt; This is correct, the IDataObject interface is provided by the object<br>&gt; that's being dragged.  Unless you're also providing the dragged<br>&gt; object the interface should be opaque.<br>&gt; <br>&gt; &gt; <br>&gt; &gt; I'm out of my depth so I'm hoping that Roger or Mark<br>&gt; &gt; or other more knowledgeable people can chip in at this point<br>&gt; &gt; and help.<br>&gt; &gt; <br>&gt; &gt; For the purposes of discussion, I attach below my test harness<br>&gt; &gt; code which creates a simple window and registers a simple<br>&gt; &gt; IDropTarget object against it.<br>&gt; &gt; <br>&gt; &gt; Sorry to be no more help than this.<br>&gt; &gt; TJG<br>&gt; &gt; <br>&gt; &gt; &lt;code&gt;<br>&gt; &gt; import os, sys<br>&gt; &gt; import win32gui<br>&gt; &gt; import win32con<br>&gt; &gt; import pythoncom<br>&gt; &gt; <br>&gt; &gt; CLSID = '{89DD545A-2C83-4103-AFE3-6CEB7FF5ECA4}'<br>&gt; &gt; PROGID = "Tim.DropTarget"<br>&gt; &gt; DESC = "Drop target handler for Tim's app"<br>&gt; &gt; <br>&gt; &gt; class DropTarget:<br>&gt; &gt;   _reg_clsid_ = CLSID<br>&gt; &gt;   _reg_progid_ = PROGID<br>&gt; &gt;   _reg_desc_ = DESC<br>&gt; &gt;   _public_methods_ = ['DragEnter', 'DragOver', 'DragLeave', 'Drop']<br>&gt; &gt;   _com_interfaces_ = [pythoncom.IID_IDropTarget]<br>&gt; &gt; <br>&gt; &gt;   def DragEnter (self, data_object, key_state, point, effect):<br>&gt; &gt;        pass<br>&gt; &gt;   def DragOver (self, key_state, point, effect):<br>&gt; &gt;        pass<br>&gt; &gt;   def DragLeave (self):<br>&gt; &gt;        pass<br>&gt; &gt;   def Drop (self, data_object, key_state, point, effect):<br>&gt; &gt;        pass<br>&gt; &gt; <br>&gt; &gt; def create_window ():<br>&gt; &gt;   def OnDestroy (hwnd, msg, wparam, lparam):<br>&gt; &gt;     win32gui.PostQuitMessage (0)<br>&gt; &gt; <br>&gt; &gt;   wc = win32gui.WNDCLASS ()<br>&gt; &gt;   hinst = win32gui.GetModuleHandle(None)<br>&gt; &gt;   wc.lpszClassName = "DragDrop"<br>&gt; &gt;   wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW;<br>&gt; &gt;   wc.hCursor = win32gui.LoadCursor (0, win32con.IDC_ARROW)<br>&gt; &gt;   wc.hbrBackground = win32con.COLOR_WINDOW<br>&gt; &gt;   wc.lpfnWndProc = {win32con.WM_DESTROY : OnDestroy}<br>&gt; &gt;   classAtom = win32gui.RegisterClass (wc)<br>&gt; &gt;   style = win32con.WS_VISIBLE | \<br>&gt; &gt;     win32con.WS_OVERLAPPED | win32con.WS_SYSMENU<br>&gt; &gt;   return win32gui.CreateWindow (<br>&gt; &gt;     classAtom,<br>&gt; &gt;     "Drag &amp; Drop demo",<br>&gt; &gt;     style,<br>&gt; &gt;     0, 0, 100, 100,<br>&gt; &gt;     0, 0, hinst, None<br>&gt; &gt;   )<br>&gt; &gt; <br>&gt; &gt; if __name__ == '__main__':<br>&gt; &gt;   pythoncom.OleInitialize ()<br>&gt; &gt;   drop_target = pythoncom.WrapObject (<br>&gt; &gt;     DropTarget,<br>&gt; &gt;     pythoncom.IID_IDropTarget,<br>&gt; &gt;     pythoncom.IID_IDropTarget<br>&gt; &gt;   )<br>&gt; &gt;   pythoncom.RegisterDragDrop (create_window (), drop_target)<br>&gt; &gt;   win32gui.PumpMessages ()<br>&gt; &gt; <br>&gt; &gt; &lt;/code&gt;<br>&gt; <br>&gt; There's a little extra work you have to do for WrapObject to work locally.<br>&gt; See \win32comext\authorization\demos\EditSecurity.py for an example.<br>&gt; <br>&gt;         Roger<br>&gt; <br>&gt; <br>&gt; <br>&gt; _______________________________________________<br>&gt; python-win32 mailing list<br>&gt; python-win32@python.org<br>&gt; http://mail.python.org/mailman/listinfo/python-win32<br><br /><hr />Messenger's gone Mobile! <a href='http://messengergonemobile.com' target='_new'>Get it now!</a></body>
</html>