Single/double clicks 
Author Message
 Single/double clicks
A VB6 query.

I want to change a whole set of label captions if I single click any of
them, but leave them unchanged and show a separate form if I double click.

Naturally double clicking will generate two events -  click and DblClick so
I need to undo the change and reset the captions in the DblClick.   This
double change of captions is visible to the application user.   Is there
any simple and elegant way of delaying the single click handling until I
know that a second one is not following?

Thanks in anticipation

Phil



Tue, 16 Aug 2005 02:28:18 GMT  
 Single/double clicks
I think that you will find that if you have the Single Click event
defined then the DoubleClick event will never fire

Basically you have to wait or rather set a flag then check whether the
next click is within 'double click time'

See the API  GetDoubleClickTime
to find how long to wait

Option Explicit

Private Declare Function GetDoubleClickTime _
                Lib "user32" () As Long

Private MaxWaitTime!

Private Sub Form_Load()
    MaxWaitTime! = GetDoubleClickTime / 1000
    Me.Caption = "Period" + Str$(MaxWaitTime!)
End Sub

Private Sub Command1_Click()
    Static HoldTime!, Count%

    Count = Count + 1
    Select Case Count
           Case 1: HoldTime = Timer
           Case 2: HoldTime = 0: Exit Sub
           Case Else: Exit Sub
    End Select

    While (Timer - HoldTime) <= MaxWaitTime
          DoEvents
    Wend

    Me.Print "Clicks" + Str$(Count)
    Me.Caption = Str$(Count)
    Count = 0

End Sub

You can slicken things up in the DoEvents loop by having a background
Timer to fire a periodic message, and inserting WaitMessage (API)
before the DoEvents

HTH

On Thu, 27 Feb 2003 18:28:18 +0000, "P.R.Brady"

Quote:

>A VB6 query.

>I want to change a whole set of label captions if I single click any of
>them, but leave them unchanged and show a separate form if I double click.

>Naturally double clicking will generate two events -  click and DblClick so
>I need to undo the change and reset the captions in the DblClick.   This
>double change of captions is visible to the application user.   Is there
>any simple and elegant way of delaying the single click handling until I
>know that a second one is not following?

>Thanks in anticipation

>Phil



Tue, 16 Aug 2005 17:40:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DataGrid: Selecting a row by single/double clicking

2. Double-click vs single-click on macro button

3. System tray icon, single click event fires before double click

4. Double clicks and single clicks

5. How to differ double click from single click?

6. Single vs Double mouse click

7. Single Quotes converted to double Single Quotes

8. Double-Click vs. click

9. Click vs Double click

10. Capture click/double-click events from datatable

11. Double-Click without Click

12. Click and Double-click events

 

 
Powered by phpBB® Forum Software