Results 1 to 2 of 2

Thread: Double Clicking the ListBar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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)...


    Code:
    '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).]

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    I just came up with some new code...
    Is this better ?

    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width