Solved

DoubleClick and MouseDown

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET Repostiory Pattern 7 37
VB.Net - TypeInitializer Error 25 27
Modal Popup Extender control 1 20
Calculate number of nights between two dates 5 24
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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