VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



An API Timer

by Kiran Prasad (1 Submission)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 18th September 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

An API Timer

Rate An API Timer




Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long

Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
     
    Public Sub AnimateLbl()

      with Form1.Lblan
       .left = .left + 30  'Move the label by 30 units
         if .left >= Form1.width then  'If the label has reached the end
           .left = -1360 'Reset Back to the Original Position
             end if
             end with    
   End Sub


'Add a command button and a label with its name to Lblan
'Add this code in Form1

            Private Sub Form_Load()
            'Set the label position
              Lblan.Left = -1360
            End Sub
    
            
            Private Sub Command1_Click()
            'Start Animation  
            SetTimer Me.hwnd, 0, 10, AddressOf Animate
            End Sub

            Private Sub Form_Unload(Cancel As Integer)
            
            'Stop the timer and animation
            'Instead you can use another button to stop
            
            'Private Sub Command1_Click()
            'KillTimer Me.hwnd, 0
            'End Sub  
            
            KillTimer Me.hwnd, 0
            End Sub


                              'Coded By Kiran.

Download this snippet    Add to My Saved Code

An API Timer Comments

No comments have been posted about An API Timer. Why not be the first to post a comment about An API Timer.

Post your comment

Subject:
Message:
0/1000 characters