Trapping a Double Click for a Toolbar Button

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 buttonhas a ButtonClick event, but if you want to trap a double-click, there is no ButtonDoubleClick event. To workaround this problem, declare two form level variables:

 Private mbSingleClicked As BooleanPrivate mbDoubleClicked As Boolean        In the Toolbars ButtonClick event, add this code:Private Sub Toolbar1_ButtonClick_        (ByVal Button As Button)Dim t As Singlet = TimerIf 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 IfEnd IfIf 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 onlyIf mbDoubleClicked = False Then        mbSingleClicked = False        mbDoubleClicked = FalseEnd IfEnd Sub
See also  Digital Signage Solutions for Agile Software Development Teams

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist