|
Option Compare Database
Option Explicit
Private Type LASTINPUTINFO
cbSize As Long
dwTime As Long
End Type
Private Declare Function GetLastInputInfo Lib "user32" (plii As LASTINPUTINFO) As Boolean
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
----------------------------------
Option Compare Database
Option Explicit
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 |
|