Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling two clicks on button 1

Status
Not open for further replies.

BasSchouten

IS-IT--Management
Jul 31, 2001
33
NL
I've got a toolbar with buttons on it. Of course there is some code in the toolbar Buttonclick event to get some things done:

Code:
Private Sub tlbMuteren_ButtonClick(ByVal Button As MSComCtlLib.Button)
    MousePointer = vbHourglass
    Debug.Print "----Button click toolbar----"
    On Error GoTo tlbMuterenClick_Error

    Select Case Button.Key
        Case "Terug"
            RaiseEvent ExitbuttonClick
        Case "Nieuw"
            AddRecord
        Case "Wijzigen"
            EditRecord
        Case "Verwijderen"
            DelRecord
        Case "Vernieuwen"
            RefreshGrid
    End Select
    
    Debug.Print "---Einde button click----"
    MousePointer = vbDefault
    Exit Sub
    
tlbMuterenClick_Error:
    MousePointer = vbDefault
    ErrorHandler Err, "tlbMuteren_Buttonclick"
    
End Sub

The problems arise when a user accidently clicks twice on the button ... the eventhandler is called a second time while the first hasnt finished yet. This of course yields all kinds of unwanted effects. I'v tried setting the mousepointer to vbHourglass but this doesnt help: my immediate window still shows the following:

Code:
----Button click toolbar----
----Button click toolbar----

Can anybody tell me how I can prevent the second buttonclick?

thanks
Bas Schouten
System Development & Webdesign
CBIS BV Holland
logo.gif
 
Perhaps at the top of your ButtonClick code you could disable the toolbar and reenable it at the end.

Chaz
 
Have you tired to stick a timer1 in your Private Sub tlbMuteren_ButtonClick(ByVal Button As MSComCtlLib.Button)
sub, and if it passes ???100ms??? then call the rest of the code in a different sub.

This is how I handle the difference between a click and double click in flexgrid.

Good luck.
 
Thanks for your suggestions, the disable trick did it!

Code:
Private Sub tlbMuteren_ButtonClick(ByVal Button As MSComCtlLib.Button)
    tlbMuteren.Enabled = false
    MousePointer = vbHourglass

    On Error goto tlbMuteren_ButtonClick_Error

    'Normal code goes here

    tlbMuteren.Enabled = true
    MousePointer = vbDefault
    Exit sub

tlbMuteren_ButtonClick_Error:
    tlbMuteren.Enabled = true
    MousePointer = vbDefault

End Sub

Bas Schouten
System Development & Webdesign
CBIS BV Holland
logo.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top