Solved

DoubleClick and MouseDown

Posted on 2006-07-09
5
795 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now