Private Declare Function GetTickCount Lib "kernel32" () As Long
Private m_LII As LASTINPUTINFO
Private Sub Form_Load()
Me.TimerInterval = 1000
End Sub
Private Sub Form_Timer()
m_LII.cbSize = Len(m_LII)
GetLastInputInfo m_LII
If (GetTickCount() - m_LII.dwTime) \ 60000 = Me.txtSeconds Then
If Me.fraOperateType = Me.optLock.OptionValue Then
DoCmd.OpenForm "frmLockSystem"
Else
DoCmd.OpenForm "frmQuitCountdown", OpenArgs:="QuitSystem"
End If
Else
On Error Resume Next
DoCmd.Close acForm, "frmQuitCountdown"
End If
End Sub
Private Sub txtSeconds_AfterUpdate()
If Nz(Me.txtSeconds, 0) <= 0 Then
Me.txtSeconds = 0
Me.TimerInterval = 0
End If
If Me.txtSeconds > 60 Then
Me.txtSeconds = 60
Else
Me.txtSeconds = Int(Me.txtSeconds)
End If
End Sub
Private Sub Form_Open(Cancel As Integer)
If Nz(Me.OpenArgs) = "QuitSystem" Then
Me.TimerInterval = 1000
Me.lblCountdown.Caption = 60
Else
Cancel = True
End If
End Sub
Private Sub Form_Timer()
Me.lblCountdown.Caption = Me.lblCountdown.Caption - 1
If Me.lblCountdown.Caption = 0 Then DoCmd.Quit acQuitSaveNone
End Sub 作者: tmtony 时间: 2014-11-1 07:14
在unload事件中关闭timer事件看看作者: andySI 时间: 2014-11-1 09:48
老師, 我不明白, 應在那裡修改?作者: tmtony 时间: 2014-11-1 16:56
在 FORM_unload