VERSION 5.00 Begin VB.UserControl TimerX Appearance = 0 'Flat BackColor = &H00C0C0C0& BorderStyle = 1 'Fixed Single CanGetFocus = 0 'False ClientHeight = 3600 ClientLeft = 0 ClientTop = 0 ClientWidth = 4800 InvisibleAtRuntime= -1 'True ScaleHeight = 3600 ScaleWidth = 4800 Begin VB.Image Image1 Height = 340 Left = 30 Stretch = -1 'True Top = 30 Width = 340 End End Attribute VB_Name = "TimerX" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long Public Event Timer() Private bEnable As Boolean Private nInterval As Long Private nID As Long Public Property Get Interval() As Long Interval = nInterval End Property Public Property Let Interval(i As Long) If Ambient.UserMode Then 'Run If bEnable Then If nID <> 0 Then If i <= 0 Then KillTimer 0, nID Set xT = Nothing nID = 0 Else KillTimer 0, nID nID = SetTimer(0, 0, i, AddressOf fTimerCallBack) End If End If Else nInterval = IIf(i > 0, i, 0) End If Else 'Design nInterval = IIf(i > 0, i, 0) End If End Property Public Property Get Enable() As Boolean Enable = bEnable End Property Public Property Let Enable(bValue As Boolean) If bValue Then If nID = 0 And nInterval > 0 Then nID = SetTimer(0, 0, nInterval, AddressOf fTimerCallBack) Set xT = Me End If Else If nID <> 0 Then KillTimer 0, nID Set xT = Nothing nID = 0 End If End If bEnable = bValue End Property Private Sub UserControl_InitProperties() bEnable = False End Sub Private Sub UserControl_ReadProperties(PropBag As PropertyBag) bEnable = PropBag.ReadProperty("Enable", False) nInterval = PropBag.ReadProperty("Interval", 0) End Sub Private Sub UserControl_Resize() UserControl.Size 28 * Screen.TwipsPerPixelX, 28 * Screen.TwipsPerPixelY End Sub Friend Sub RaiseTimer() RaiseEvent Timer End Sub Private Sub UserControl_Terminate() If nID <> 0 Then KillTimer 0, nID nID = 0 Set xT = Nothing End If End Sub Private Sub UserControl_WriteProperties(PropBag As PropertyBag) Call PropBag.WriteProperty("Enable", bEnable, False) Call PropBag.WriteProperty("Interval", nInterval, 0) End Sub