{"id":26963,"date":"2007-05-07T10:00:00","date_gmt":"2007-05-07T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2007\/05\/07\/drag-and-drop-is-a-general-purpose-transfer-model-not-exclusive-to-explorer-directories\/"},"modified":"2007-05-07T10:00:00","modified_gmt":"2007-05-07T10:00:00","slug":"drag-and-drop-is-a-general-purpose-transfer-model-not-exclusive-to-explorer-directories","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20070507-00\/?p=26963","title":{"rendered":"Drag and drop is a general purpose transfer model, not exclusive to Explorer directories"},"content":{"rendered":"<p>If you&#8217;ve designed your program so that it assumes that the the only thing a user can use drag\/drop for is dropping your object into a file system directory, then you&#8217;ve already lost.\n <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#428702\"> piers wants to be able to determine the destination of a drag\/drop operation<\/a>. From the description, it appears that what piers really wants is the destination <strong>path<\/strong>, but who says that the drop destination is a directory? The user might have dropped the item into an email message, onto an FTP site, onto a Web site (via Web Folders), or even a directory on an operating system running inside a virtual machine!\n <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#428714\"> The follow-up question makes things even more confusing<\/a>. If the user drops the files into an FTP site or some other virtual folder, how is your program supposed to be able to restart the transfer? You don&#8217;t know the user&#8217;s password on that FTP site. You don&#8217;t know how to restart that virtual machine and log the user on. And even if you did, you don&#8217;t know how to write to a directory on a virtual machine; only the virtual machine manager knows how to do that. There are an infinite variety of potential virtual folders out there; I doubt you know how to (or even have the ability to) push your data into each one.\n Once the user drops the data object, the remainder of the transfer is a private matter between the data source and the drop target. It&#8217;s not like a data source can tell all drop targets, &#8220;I want to take over the transfer,&#8221; because even if the drop target agreed to it, that still leaves the data source the problem of  figuring out how to carry out that take-over.\n What is my recommendation?&Dagger;\n The data object in the drag\/drop loop should follow the standard shell data object transfer protocol so that users can drop the object into an email message, onto an FTP site, etc.&deg;\n For the special bonus behavior, I would create a drag\/drop hook. A user that wants to do a transfer mediated by your program can use the right mouse button&dagger; to drag. When the drop occurs, a context menu will appear, including the drag\/drop hook you created. That hook would create a new item called something like &#8220;Copy with CoolProgram&#8221;. (Of course, the hook adds this item only if the data object identifiers itself as coming from CoolProgram.) If the user selects &#8220;Copy with CoolProgram&#8221;, then you can do your CoolProgram-mediated copy.\n <b>Nitpicker&#8217;s corner<\/b>\n &dagger;More properly, the secondary mouse button, since you may have swapped buttons.\n &Dagger;<a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/07\/13\/664448.aspx\">Notice that I do not assert<\/a> that all Microsoft products follow my recommendation. Note also that this is my personal recommendation, not the official position of Microsoft Corporation.<\/p>\n<p> &deg;And you should already understand the standard shell data object transfer protocol before you go off and design a nonstandard one. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve designed your program so that it assumes that the the only thing a user can use drag\/drop for is dropping your object into a file system directory, then you&#8217;ve already lost. piers wants to be able to determine the destination of a drag\/drop operation. From the description, it appears that what piers really [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-26963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>If you&#8217;ve designed your program so that it assumes that the the only thing a user can use drag\/drop for is dropping your object into a file system directory, then you&#8217;ve already lost. piers wants to be able to determine the destination of a drag\/drop operation. From the description, it appears that what piers really [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/26963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=26963"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/26963\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=26963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=26963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=26963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}