Dave Nottage 557 Posted January 31, 2022 This answer has served me well for some time now: https://stackoverflow.com/a/13835244/3164070 however it does not work for when a user drags an attachment from Outlook (it works when dragging the entire email). Does anyone know if an object of a different name is created, or perhaps some other "event" occurs? I'm otherwise looking at installing a global mouse hook as @Remy Lebeau suggests in one of the other answers in the same SO post. Share this post Link to post
Vincent Parrett 750 Posted January 31, 2022 (edited) Hi Dave I suspect that might not be using the standard windows drag and drop - more likely an OLE one. The VirtualTreeView source code might offer a clue on how to implement that as has a dragtype property of dtVCL or dtOLE - disclaimer - I have never used the OLE type so don't know much about it. Edited January 31, 2022 by Vincent Parrett typo 1 Share this post Link to post
angusj 126 Posted January 31, 2022 (edited) Quote Detecting start of drag operations guessing ... startDragEvent := SetWinEventHook(EVENT_OBJECT_DRAGSTART, EVENT_OBJECT_DRAGSTART, 0, @DragStartEvent, 0, 0, WINEVENT_OUTOFCONTEXT); procedure DragStartEvent(hWinEventHook: THandle; event: DWORD; hwnd: HWND; idObject, idChild: Longint; idEventThread, dwmsEventTime: DWORD); stdcall; begin //do stuff end; Note: All OLE drag events are initiated by DoDragDrop https://docs.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-dodragdrop Since the drag souce (IDropSource, IDataObject) is initiated by another process so you'll certainly need a system event hook. Edited January 31, 2022 by angusj Share this post Link to post
Dave Nottage 557 Posted January 31, 2022 17 minutes ago, angusj said: guessing ... As promising as that looked, it didn't help 🙂 Share this post Link to post
angusj 126 Posted January 31, 2022 (edited) 37 minutes ago, Vincent Parrett said: I suspect that might not be using the standard windows drag and drop - more likely an OLE one. Is there a difference between OLE and "the standard windows drag and drop"? "The OLE DoDragDrop function calls this method (IDropSource::QueryContinueDrag) during a drag-and-drop operation." https://docs.microsoft.com/en-us/windows/win32/api/oleidl/nn-oleidl-idropsource Of course, this is very different to Delphi's custom drag drop stuff. Edited January 31, 2022 by angusj Share this post Link to post
angusj 126 Posted January 31, 2022 37 minutes ago, Dave Nottage said: As promising as that looked, it didn't help 🙂 Despite the lack of documentation on EVENT_OBJECT_DRAGSTART here: https://docs.microsoft.com/en-us/windows/win32/winauto/event-constants it seems likely that this event is only triggered by "UI Automation" Drag-and-Drop https://docs.microsoft.com/en-us/windows/win32/winauto/ui-automation-support-for-drag-and-drop Share this post Link to post
Anders Melander 1784 Posted January 31, 2022 Can you explain why you need to know when a drag is initiated? It's a rather unusual requirement. Share this post Link to post
Remy Lebeau 1397 Posted January 31, 2022 (edited) 10 hours ago, angusj said: Is there a difference between OLE and "the standard windows drag and drop"? Not really, no. Windows uses OLE for cross-process drag&drop. For backwards compatibility, if the receiving process does not implement IDropTarget, OLE synthesizes the legacy WM_DROPFILES window message for it. Quote Of course, this is very different to Delphi's custom drag drop stuff. Yes, in-process drag&drop is the responsibility of the process to implement. There is no Win32 API support for it outside of OLE, so the process can basically use whatever it wants. Edited January 31, 2022 by Remy Lebeau 1 Share this post Link to post
Achim Kalwa 61 Posted February 1, 2022 (edited) On 1/31/2022 at 6:36 AM, Dave Nottage said: This answer has served me well for some time now: https://stackoverflow.com/a/13835244/3164070 however it does not work for when a user drags an attachment from Outlook (it works when dragging the entire email). Does anyone know if an object of a different name is created, or perhaps some other "event" occurs? Have a look at this plugin for Outlook which enables drag & drop of any item to applications: https://github.com/tonyfederer/OutlookFileDrag Maybe you find out how it works and port the code to Delphi. If you succeed, please make your solution open source, because I would like to implement it to our application, too 😉 Currently we rely on this plugin. Edited February 1, 2022 by Achim Kalwa . Share this post Link to post
Anders Melander 1784 Posted February 1, 2022 4 minutes ago, Achim Kalwa said: Have a look at this plugin for Outlook which enables drag & drop of any item to applications: https://github.com/tonyfederer/OutlookFileDrag You don't need a plugin to receive items dragged from outlook. You just need to handle the correct clipboard format and any decent drag/drop library can do that for you. https://github.com/landrix/The-Drag-and-Drop-Component-Suite-for-Delphi Share this post Link to post
angusj 126 Posted February 2, 2022 4 hours ago, Anders Melander said: You don't need a plugin to receive items dragged from outlook. You just need to handle the correct clipboard format That seems likely be the solution to Dave Nottage's problem, though it isn't the answer to his question 😁. Share this post Link to post
Anders Melander 1784 Posted February 2, 2022 3 hours ago, angusj said: That seems likely be the solution to Dave Nottage's problem, though it isn't the answer to his question 😁. Well, the answer to his question is "yes" but since we don't really know what problem he's trying to solve it's hard to tell... 🙂 Share this post Link to post
Dave Nottage 557 Posted February 2, 2022 (edited) 4 hours ago, angusj said: That seems likely be the solution to Dave Nottage's problem I'd like to know how it is the likely solution. Please refer to the original question. 29 minutes ago, Anders Melander said: Well, the answer to his question is "yes" but since we don't really know what problem he's trying to solve it's hard to tell The problem I am trying to solve is in the original question. The "why" is that a WVD app is on the receiving end of the drag operation, and the virtual channel needs to register the WVD app window for drag/drop. The best time to do this is at the start of the operation. As I say, this has been working famously for standard drag/drop, but it does not work for dragging attachments out of Outlook Edited February 2, 2022 by Dave Nottage Share this post Link to post