PDA

Click to See Complete Forum and Search --> : Double Clicking the ListBar


Inhumanoid
Dec 7th, 1999, 04:57 PM
The listbar does not have a ListItemDoubleClick event
My problem is that I have a listbar and a double click must be treated like a single click....I've come up with quite a good one (at least I think so)...

Here's my code... Please give me feedback..
plz be very critical cause I want this code to be fine and dandy(thank you)...



'API to get machines DoubleClickTimePrivate Declare Function GetDoubleClickTime& Lib "user32" ()
Private Sub Form_Activate() Timer1.Interval = GetDoubleClickTime
End Sub

Private Sub SSListBar1_ListItemClick(ByVal ItemClicked As Listbar.SSListItem)
Static sKey As String
If Timer1.Enabled And ItemClicked.Key = sKey Then
Text1.Text = "Double Clicked... Ignore last click..."
Exit Sub
End If
Timer1.Enabled = True
sKey = ItemClicked.Key
Label1.Caption = "Slic was opened by " & ItemClicked.Text
Text1.Text = ""
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
End Sub


[This message has been edited by Inhumanoid (edited 12-08-1999).]

Inhumanoid
Dec 7th, 1999, 07:50 PM
I just came up with some new code...
Is this better ?


Private Declare Function GetDoubleClickTime& Lib "user32" ()

Private Sub SSListBar1_ListItemClick(ByVal ItemClicked As Listbar.SSListItem)
Static dClick As Double
Static sKey As String

If dClick + (GetDoubleClickTime / 1000) > Timer And sKey = ItemClicked.Key Then
'This is a true double click so we leave the sub
dClick = 0
Exit Sub
Else
'User too slow or different Listitem
dClick = 0
End If

If dClick = 0 Then
'True first click or too slow second click
dClick = Timer
End If

sKey = ItemClicked.Key


'All other code goes here...

End Sub