Home > Software engineering >  I would like to ask VB, double-click the mouse events will lead to the click event, so how to solve
I would like to ask VB, double-click the mouse events will lead to the click event, so how to solve

Time:09-24

Same as above,

Private Sub Form_Click ()
Form1. Width=Form1. Width + 1000
End Sub

Private Sub Form_DblClick ()
Unload Me
End Sub

Private Sub Form_Load ()
Form1. BackColor=RGB (255, 255, 0)
End Sub
Private Sub Form_Unload (Cancel As Integer)
A=MsgBox (" whether to unload the form ", vbYesNo, "message")
If a=7 Then
Cancel=2
End the If
End Sub

CodePudding user response:

So, this is you have a design problem. Double-click the inevitably lead to click, because it is two consecutive single ah.

Solution: you can be done by right-clicking on the had the function of the left key click
You can use the button in the mousedown event parameters to determine the key pressed is left or right.

CodePudding user response:

Click click is triggered, double-click will trigger, the two can only choose one, the problem of design,

If this capricious to there is a way, usually double click interval is 500 ms, you stop a 600 ms after the click, see if there are any double-click, no if you click on the process, so just ignore them click, to execute the double-click events in the process,

CodePudding user response:

 Dim isDblClick As Boolean 

Private Sub Form_Click ()
IsDblClick=False

Dim lngFinish As Long
LngFinish=Timer + 0.6
The Do While the Timer & lt; LngFinish
DoEvents
Loop

If Not isDblClick Then
The Print Now & amp; "Click"
End the If
End Sub

Private Sub Form_DblClick ()
IsDblClick=True
The Print Now & amp; "Double click"
End Sub

Double-click on the speed of each computer is different, usually it can use the above code, otherwise you have to adjust myself,
  • Related