Every time i want let the user to drag an control, i calling DoDragDrop of that control.
The drag & drop works fine, but i have problem with things around:
You need to forget about using a thread, that's only going to deliver D+D notifications to the windows that were created on that thread. Which will not be your controls.
I can't do much with a "code is sucks" diagnostic. The DoDragDrop() call itself will indeed block until the mouse button is released. Another message loop, internal to COM code will take over and deliver the Windows messages. Timer and paint messages should be delivered as normal. A diagnostic is very hard to come by until you post some repro code.
You probably want the DoDragDrop
to quit and do the job asynchronously.
Here is the answer.
The DoDragDrop method stops processing of events until first mouse event (for example mouse move). So the workaround I found is very simple - you just need to simulate mouse event with the same mouse position just before calling DoDragDrop:
void XYZControl_MouseDown(object sender, MouseEventArgs e)
{
var senderControl = (Control) sender;
...
Cursor.Position = senderControl.PointToScreen(new Point(e.X, e.Y)); // Workaround!
if (DoDragDrop(senderControl, DragDropEffects.Move) == DragDropEffects.Move)
{
...
}
....
}