|
|
Title | Ignore events during a long process by disabling the form |
Keywords | ignore events, events, disable |
Categories | Tips and Tricks, Controls |
|
|
Disable the form(s) whose events you want to ignore.
This example sets the form's Enabled property to False and then starts a 5 second countdown. All events are ignored until the count finishes and the program sets Enabled to True.
|
|
Private Sub Command1_Click()
Enabled = False ' Disable the form.
Screen.MousePointer = vbHourglass
Label1.Caption = "5"
m_Count = 5
DoEvents
Timer1.Enabled = True
End Sub
' Count down from 5.
Private Sub Timer1_Timer()
m_Count = m_Count - 1
Label1.Caption = Format$(m_Count)
If m_Count = 0 Then
Timer1.Enabled = False
Enabled = True ' Enable the form
Screen.MousePointer = Default
End If
End Sub
|
|
|
|
|
|