Solved

DoubleClick and MouseDown

Posted on 2006-07-09
5
797 Views
Last Modified: 2009-02-12
Im using MouseDown, MouseMove and MouseUp to reposition controls on a panel. I also need to use DoubleClick but the problem is the MouseDown-Move-Up sequence is performed when I double click on the control. If someone has some example code for this it would be really nice to see.

Thanks
0
Comment
Question by:craigdev
  • 2
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
vadim63 earned 250 total points
ID: 17070186
I had the same problem. I've found a good example for DragDrop, but you can use it for any purposes:

" The idea is to wait with starting the DoDragDrop event until the doubleclick event should have fired, if that hasn't fired, then do it. The code, in case other people run into the same problem:

Class variable
Private IsWaitingForDoubleClick As Boolean

Set during load (Add a timer first)
Timer1.Interval = SystemInformation.DoubleClickTime

Private Sub DocList_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DocList.MouseMove
    If Not e.Button = MouseButtons.Left Then Return
    StartWaitForDoubleClick()
End Sub
Private Sub DocList_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DocList.MouseUp
    EndWaitForDoubleclick()
End Sub

Private Sub StartWaitForDoubleClick()
    'This remains true until the timer fires, or the mouse button is released
    IsWaitingForDoubleClick = True
    Timer1.Enabled = True
End Sub
Private Sub EndWaitForDoubleclick()
    IsWaitingForDoubleClick = False
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If IsWaitingForDoubleClick Then
        IsWaitingForDoubleClick = False
        StartDragDrop()
    End If
    sender.Enabled = False
End Sub

Private Sub StartDragDrop()
    DocList.DoDragDrop(DocList.SelectedItems(0),DragDropEffects.Copy)
End Sub

This way the mouseClick and mouseDoubleClick events will fire as normally, and you can put any code you like into there."
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17070277
Check e.Clicks for a value > 1.

Bob
0
 
LVL 1

Author Comment

by:craigdev
ID: 17070297
In which function, MouseMove, Up or Down? I tried all three so Im not sure what you mean
0
 
LVL 1

Author Comment

by:craigdev
ID: 17070531
>> Check e.Clicks for a value > 1
Please elaborate, thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17072197
I imagine the MouseMove event, since it is normally where the work is done, but you have to tell me.  Not enough information there to really say.

Bob
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question