{"id":37093,"date":"2004-12-08T07:00:00","date_gmt":"2004-12-08T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/12\/08\/dragging-a-shell-object-part-3-detecting-an-optimized-move\/"},"modified":"2004-12-08T07:00:00","modified_gmt":"2004-12-08T07:00:00","slug":"dragging-a-shell-object-part-3-detecting-an-optimized-move","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20041208-00\/?p=37093","title":{"rendered":"Dragging a shell object, part 3: Detecting an optimized move"},"content":{"rendered":"<p><P>\nWe were considering how to detect that the drag\/drop operation\nresulted in a conceptual Move even if the <CODE>DROPEFFECT_MOVE<\/CODE>\nwas optimized away.\n<\/P>\n<P>\nIf the drop target is the shell, you can query the\ndata object for <CODE>CFSTR_PERFORMEDDROPEFFECT<\/CODE>\nto see what the performed effect was.\n<\/P>\n<PRE>\nvoid OnLButtonDown(HWND hwnd, BOOL fDoubleClick,\n                   int x, int y, UINT keyFlags)\n{\n  &#8230;\n        if (dwEffect &amp; DROPEFFECT_MOVE) {\n          DeleteFileW(wszPath);\n        }\n        <FONT COLOR=\"blue\">CheckPerformedEffect(hwnd, pdto);<\/FONT>\n  &#8230;\n}\n<\/PRE>\n<P>\nOf course, we need that <CODE>CheckPerformedEffect<\/CODE>\nfunction too.\n<\/P>\n<PRE>\nvoid CheckPerformedEffect(HWND hwnd, IDataObject *pdto)\n{\n  FORMATETC fe = {\n     (CLIPFORMAT)RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT),\n     NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };\n  STGMEDIUM stgm;\n  if (SUCCEEDED(pdto-&gt;GetData(&amp;fe, &amp;stgm))) {\n    if ((stgm.tymed &amp; TYMED_HGLOBAL) &amp;&amp;\n        GlobalSize(stgm.hGlobal) &gt;= sizeof(DWORD)) {\n       DWORD *pdw = (DWORD*)GlobalLock(stgm.hGlobal);\n       if (pdw) {\n         if (*pdw == DROPEFFECT_MOVE) {\n            MessageBox(hwnd, TEXT(&#8220;Moved&#8221;), TEXT(&#8220;Scratch&#8221;), MB_OK);\n         }\n         GlobalUnlock(stgm.hGlobal);\n       }\n    }\n    ReleaseStgMedium(&amp;stgm);\n  }\n}\n<\/PRE>\n<P>\nIf the item is dropped on a shell window, the drop target\nwill set data into the data object under the clipboard format name\n<CODE>CFSTR_PERFORMEDDROPEFFECT<\/CODE>.\nThe data takes the form of a <CODE>DWORD<\/CODE> in an\n<CODE>HGLOBAL<\/CODE>, and the value is the actual drop effect\nbefore any optimizations kicked in.\n<\/P>\n<P>\nHere, we check whether it was a <CODE>DROPEFFECT_MOVE<\/CODE> and\ndisplay a special message if so.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We were considering how to detect that the drag\/drop operation resulted in a conceptual Move even if the DROPEFFECT_MOVE was optimized away. If the drop target is the shell, you can query the data object for CFSTR_PERFORMEDDROPEFFECT to see what the performed effect was. void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-37093","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>We were considering how to detect that the drag\/drop operation resulted in a conceptual Move even if the DROPEFFECT_MOVE was optimized away. If the drop target is the shell, you can query the data object for CFSTR_PERFORMEDDROPEFFECT to see what the performed effect was. void OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37093","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=37093"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37093\/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=37093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=37093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=37093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}