1) Place an UltraDayView control on a form
2) Go to the MouseMove event of the control
3) Add some code to let you see when the event is being fired (i.e. have a label as a counter which increases each time the event fires)
4) Run the application.
Hover the mouse over the control, now DO NOT MOVE THE MOUSE for the next instructions.
Press the mouse button down to select a timeslot. When you release the mouse button, you will see that the event has fired.
Now click the mouse button on the timeslot you selected again. This time the event fires twice.
The mouse cursor has not moved during any of these operations - yet the mousemove event is being fired. What gives? Surely this is not the expected behaviour. It is causing me headaches because im dealing with drag and drop while also trying to keep the double click event working correctly.
I'm pretty sure what you are describing is the way Windows has always issued mouse messages. In any case we have no control over it because we don't do anything for the MouseMove event, it is inherited from the System.Windows.Forms.Control class.
There is a small but important difference.
In a normal microsoft control, the event is raised when you release the mouse button. In your controls, the event is raised when you press the button down AND when you release the button - but this behaviour only happens when you are clicking on a timeslot that is already selected.
The reason this is a problem for me is because im trying to implement a customised drag and drop facility but it is causing me problems because its conflicting with the doubleclick event. The fact that the event fires when the mouse is released isnt really a problem for me - its only a problem if the event fires when the mouse is pressed down, which only seems to happen with the infragistics control.
I have found the dayview behaviour slightly different to the other controls i tested (which didnt include the treeview though) in that it fires on the mouse down if you click a timeslot that is already selected (even if its not the first mouse down in the app) but i understand that there is some odd behaviour in the way microsoft initiates the MouseMove event in the Control class and your suggestion sounds good ill try that. Thanks.
I tried he following to investigate your claim:
this.dayView.MouseMove += new MouseEventHandler(this.OnMouseMove);this.treeView1.MouseMove += new MouseEventHandler(this.OnMouseMove);
void OnMouseMove(object sender, MouseEventArgs e){ if ( e.Button != MouseButtons.None ) Debug.WriteLine( ((Control)sender).Name + ": OnMouseMove" );}
UltraDayView behaved exactly the same as the TreeView. For both controls, the event fired on a MouseDown without moving, but only for the first mouse down on any control in the application. I found that odd, but this is .NET runtime behavior, not ours. I did not see the event being raised when the mouse button was released; the most likely explanation is that the mouse actually moved - if you didn't programmatically screen for the mouse button state, it would be extremely difficult to know just by whether you think your hand moved.
The recommended way to initate a drag drop operation is to handle MouseDown and MouseMove. You record the point at which the button was pressed in MouseDown, then in MouseMove, you check to see whether the button is down, and if the cursor position is outside a rectangle centered around the original point, whose size is defined by the static System.Windows.Forms.SystemInformation.DragSize property.