3

We need to display a feedback to the user when he drags-in items into our application. Our client prefers this feedback to be in form of a custom cursor.

This is already implemented for drag-out, using a custom cursor that is set in GiveFeedback event handler (raised by DoDragDrop when dragging items out of our app). The GiveFeedbackEventArgs allows us to specify UseDefaultCursors property - setting this to false allows us to override the cursor.

However, the DragOver event handler argument, which is the equivalent of GiveFeedback, does not have UseDefaultCursors property and changing the cursor from there does not have any effect.

Sample (this has no effect):

private void browser_DragOver(object sender, DragEventArgs e) {
  Cursor.Current = Cursors.WaitCursor;
}

The drag operation originates from outside our app. (for in-app drag, it works using the GiveFeedback event.

How to change the cursor when receiving a drag? Is this even possible/feasible?

Marek
  • 10,307
  • 8
  • 70
  • 106

4 Answers4

3
void Form1_GiveFeedback(object sender, GiveFeedbackEventArgs e) {
    e.UseDefaultCursors = false;
}
Barrakoda
  • 39
  • 2
  • Welcome on SO, here, it is a good practice to explain why to use your solution and not just how. That will make your answer more valuable and help further reader to have a better understanding of how you do it. I also suggest that you have a look on our FAQ : http://stackoverflow.com/faq. – ForceMagic Oct 26 '12 at 05:26
  • See here http://msdn.microsoft.com/en-us/library/system.windows.forms.control.givefeedback(v=vs.110).aspx – Mladen Mihajlovic Dec 06 '13 at 22:11
2

Yes, you must implement a COM interfaces (IDragSourceHelper and IDropTargetHelper). Take a look HERE.

CodeGuru
  • 36
  • 2
1

Would this suffice?
This code will change the mouse pointer by adding a [+] sign next to it.

private void Form_DragOver(object sender, DragEventArgs e)
{
    e.Effect = DragDropEffects.Copy;
}
Jakob Möllås
  • 4,239
  • 3
  • 33
  • 61
-2

We've addressed a whole range of drag-drop issues here:

Drag and Drop between Instances of the same Windows Forms Application

Hopefully this will point you in the right direction.

Community
  • 1
  • 1
Pedery
  • 3,632
  • 1
  • 27
  • 39