Drag+Drop and MouseClick

J

JezB

I want to allow a user control to respond to drag+drop operations, and also
to a MouseClick or Click event. It seems I can only do one or the other. The
reason seems to be that as soon as you handle a MouseDown event and call
DoDragDrop for a POTENTIAL drag/drop operation, it will no longer fire a
MouseClick or Click event on that control (ie. when you haven't dragged the
control, you have just clicked on it).

What is the best way round this ?
 
B

Bob Powell [MVP]

You have to look at the context and figure it out for yourself.

For example, a drag operation must drag something so if the mouse isn't in a
draggable thing, handle it as a normal click, if it is, start a drag
operation.

Dropping has nothing to do with mouse clicks so that has no bearing on the
problem.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
S

Stoitcho Goutsev \(100\)

JezB,

In addition to what Bob said about implementing D'n'D operation I want to
add that good implemented D'n'D doesn't start the operation on mouse down.
The drag operation has to start if the user presses the mouse button and
moves the mouse on a certain distance from the button-down point. Only if
this happens and all other conditions are met (see Bob's post) the
operation should be considered as starting D'n'D.

SystemInformation class has a property DragSize that should be used for the
size of the rectangle arround the click point in which the drag operation
shouldn't start.
 
J

JezB

Good advice that - thanks.

Stoitcho Goutsev (100) said:
JezB,

In addition to what Bob said about implementing D'n'D operation I want to
add that good implemented D'n'D doesn't start the operation on mouse down.
The drag operation has to start if the user presses the mouse button and
moves the mouse on a certain distance from the button-down point. Only if
this happens and all other conditions are met (see Bob's post) the
operation should be considered as starting D'n'D.

SystemInformation class has a property DragSize that should be used for
the size of the rectangle arround the click point in which the drag
operation shouldn't start.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top