dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 1, 1997

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Trapping a Double Click for a Toolbar Button

VB4 supports the built-in Win95 Toolbar control, which allows users to add Buttons to the toolbar. The button has a ButtonClick event, but if you want to trap a double-click, there is no ButtonDoubleClick event. To work around this problem, declare two form level variables:
 
Private mbSingleClicked As Boolean
Private mbDoubleClicked As Boolean

        In the Toolbars ButtonClick event, add this code:

Private Sub Toolbar1_ButtonClick_
        (ByVal Button As Button)
Dim t As Single
t = Timer
If mbSingleClicked = True Then
        mbDoubleClicked = True
        MsgBox "Double Clicked"
Else
        mbSingleClicked = True
        ' allow the user to click the next 
        ' time if he wants to double click
        Do While Timer - t < 1 And mbSingleClicked = True
                DoEvents
        Loop
        ' if the user has selected a double 
        ' click end the sub.
        If mbDoubleClicked = True Then
                mbSingleClicked = False
                mbDoubleClicked = False
                Exit Sub
        End If
End If
If mbDoubleClicked = False Then 
        MsgBox "Single Clicked"
End If

'you can do the processings here, e.g
'If mbDoubleClicked Then
'--------- code
'ElseIf mbSingleClicked Then
'--------- code
'End If

'when exiting from the sub please 
'reintialize the variables, otherwise we 
'will end up with the single clicks only
If mbDoubleClicked = False Then
        mbSingleClicked = False
        mbDoubleClicked = False
End If
End Sub
Sushrut Nawathe
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date