Solved

DoubleClick and MouseDown

Posted on 2006-07-09
5
794 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
Comment Utility
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
Comment Utility
Check e.Clicks for a value > 1.

Bob
0
 
LVL 1

Author Comment

by:craigdev
Comment Utility
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
Comment Utility
>> Check e.Clicks for a value > 1
Please elaborate, thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

12 Experts available now in Live!

Get 1:1 Help Now