Drag and Drop Files mystery in VS2017

gui

#1

There seems to be a strange difference between VS2017 and VS2015:
Running an application with Files Drag and Drop doesn’t work, if run from within VS2017 IDE, but works fine within VS2015. Applies to Debug or non-Debug start.
If run directly from Explorer, in all cases Drag’n’Drop works fine, even with attached VS2017 debugger. The app is made with VS2017 settings and not rebuild for VS2015.
Is there an explanation for this?
(As an example, I used the Demo widget.h app)


#2

I’ve tested this with VS2017 and I’m not seeing any issues, I can drop files into the “Drag & Drop” section of the widgets demo and they’re showing up correctly. Can you put a breakpoint in filesDropped() method of the DragAndDropDemoTarget class in the widgets demo and see if it’s being called?


#3

I did, it’s not called at all. Using Spy++, I can see, that the app doesn’t receive any WM_DROPFILE messages (when running from VS2017).
As I said, when I start the app outside VS2017, attach VS2017 debugger and then set the breakpoint, I’m getting a hit.


#4

Solved the problem! I used to start the IDE as Admin, and I learned that drag’n’drop doesn’t work with elevated IDE. After reinstalling the IDE it’s working now.


#5

To be more specific, it’s not just the IDE: also your application, if started in Admin mode even outside the IDE, will not receive drag and drop events.

I guess it is a security measure of some sort, to prevent inadvertent sharing of data from “normal user context” to “privileged admin context”