Results 1 to 4 of 4

Thread: Microsoft Code For The Construction Of A Timer

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Post

    I need the Microsoft Code For The Construction Of A Timer. I need it to build a new timer so that it can fit in with my other components!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Angry

    All I ask is for someone to post the original timer component code. Other people ask the hardest questions and you reply to them. This is so simple! Like NIKE says, JUST DO IT!!!

  3. #3
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Thumbs down

    Have you asked Microsoft for the code?

    I am pretty sure they would be willing to send it to you royalty free...................Not!

    Do what we all do.......write your own.

    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  4. #4
    Guest
    I wrote a code for this about a month ago. It's not that hard once you look at it. Basically this uses GetTickCount for accuracy up to 1ms.

    Put the following in a UserControl (call it TimerEx)
    Code:
    'Default Property Values:
    Const m_def_Enabled = 0
    Const m_def_Interval = 0
    'Property Variables:
    Dim m_Enabled As Boolean
    Dim m_Interval As Integer
    'Event Declarations:
    Event Timer()
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    
    Public Property Get Enabled() As Boolean
        Enabled = m_Enabled
    End Property
    
    Public Property Let Enabled(ByVal New_Enabled As Boolean)
        m_Enabled = New_Enabled
        PropertyChanged "Enabled"
        Do While m_Enabled = True
            start = GetTickCount
            Do While GetTickCount < start + m_Interval
                DoEvents
            Loop
                
            RaiseEvent Timer
        Loop
    End Property
    
    Public Property Get Interval() As Integer
        Interval = m_Interval
    End Property
    
    Public Property Let Interval(ByVal New_Interval As Integer)
        m_Interval = New_Interval
        PropertyChanged "Interval"
    End Property
    
    'Initialize Properties for User Control
    Private Sub UserControl_InitProperties()
        m_Enabled = m_def_Enabled
        m_Interval = m_def_Interval
    End Sub
    
    'Load property values from storage
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    
        m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
        m_Interval = PropBag.ReadProperty("Interval", m_def_Interval)
    End Sub
    
    'Write property values to storage
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
        Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
        Call PropBag.WriteProperty("Interval", m_Interval, m_def_Interval)
    End Sub
    Put the following in a Form with a CommandButton and a TimerEx.
    Code:
    Private Sub Command1_Click()
        TimerEx1.Interval = 500
        TimerEx1.Enabled = True
    End Sub
    
    Private Sub TimerEx1_Timer()
        Print "Hello"
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width