⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctimeout.cls

📁 本书源码主要针对目前流行的FTP、HTTP、E-mail、Telnet、ICMP、Modem串口通信编程、拨号网络编程等内容进行详细的讲解
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CTimeout"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'SetTimer函数创建一个有时间限制的定时器
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
'KillTimer函数销毁一个特定的定时器
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

Private m_lngTimerID As Long
Private m_intTimeoutValue As Integer
'

Public Sub StartTimer()
'启动定时器
    If m_lngTimerID > 0 Then
        '如果原来有定时器,则销毁
        KillTimer 0, m_lngTimerID
    End If
    MFtpSupport.p_intCounter = 0
    '创建定时器
    m_lngTimerID = SetTimer(0, 0, 1000, AddressOf MFtpSupport.TimerProc)

End Sub
'销毁定时器
Public Sub StopTimer()

    MFtpSupport.p_intCounter = 0
    KillTimer 0, m_lngTimerID

End Sub
'设定TimeoutValue属性值,用来设置限制时间
Public Property Let TimeoutValue(NewValue As Integer)
    m_intTimeoutValue = NewValue
End Property
'获得TimeoutValue属性值
Public Property Get TimeoutValue() As Integer
    TimeoutValue = m_intTimeoutValue
End Property
'获得timeout属性,用来判断是否已经超时
Public Property Get Timeout() As Boolean

    If MFtpSupport.p_intCounter > m_intTimeoutValue Then
        Timeout = True
        Call StopTimer
    Else
        Timeout = False
    End If
    
End Property
'让计时器回0
Public Sub Reset()

    MFtpSupport.p_intCounter = 0

End Sub
'类销毁的时候,同时销毁定时器
Private Sub Class_Terminate()
    Call StopTimer
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -