How to check if the user is dragging any files/folders over my form? lazarus / 31-LCL ---------------------------------------------------------------------- rsz · 2021-08-08 15:47 Hi, I've written a GUI program to do some processing when the user drops files and folders onto the form. It works with the OnDropFiles event and processes whatever files and folders get dropped on it. To make my program a bit nicer I would like to change the look of my form when the user drags anything from the desktop over it. We've got OnMouseEnter and OnMouseLeave events for when the cursor enters or leaves my form, but how can I check if the user is currently dragging files/folders? I can't find any way to do this without writing widgetset specific code but maybe I'm overseeing something. ---------------------------------------------------------------------- Remy Lebeau · 2021-08-08 23:56 Quote from: rsz on August 08, 2021, 05:47:01 pmhow can I check if the user is currently dragging files/folders? AFAIK, when using the OnDropFiles event, there is no way to determine that. On Windows at least, you can instead write a class which implements the IDropTarget interface, specifically its DragEnter(), DragLeave(), and Drop() methods.  And then you can assign an object instance of that class to your window using RegisterDragDrop(). ---------------------------------------------------------------------- rsz · 2021-08-09 05:07 Thanks Remy, I was hoping I didn't have to write widgetset/platform specific code but it seems like it's not possible otherwise. I'll see if I can write a small class which abstracts this for the different widgetsets/platforms and only expose a simple IsDraggingFiles property or similar. ---------------------------------------------------------------------- howardpc · 2021-08-09 10:38 If the dragged file/folders are part of your application, TControl has a Dragging property you can query. ---------------------------------------------------------------------- lucamar · 2021-08-09 11:17 Quote from: howardpc on August 09, 2021, 12:38:29 pmIf the dragged file/folders are part of your application, TControl has a Dragging property you can query. That is meant for (and only works for) drag&drop of controls themselves; nothing to do at all with files/folders.