home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH5 / SRC / BOUNCER.BAS < prev    next >
Encoding:
BASIC Source File  |  1996-05-04  |  1.4 KB  |  49 lines

  1. Attribute VB_Name = "BouncerFuncs"
  2. Option Explicit
  3.  
  4. #If Win32 Then
  5.     Declare Function GetTickCount Lib "kernel32" () As Long
  6.     Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
  7. #Else
  8.     Declare Function GetTickCount Lib "User" () As Long
  9.     Declare Sub SetCursorPos Lib "User" (ByVal X As Integer, ByVal Y As Integer)
  10. #End If
  11.  
  12. ' ************************************************
  13. ' Pause until GetTickCount shows the indicated
  14. ' time. This is accurate to within one clock tick
  15. ' (55 ms), not counting variability in DoEvents
  16. ' and Windows itself.
  17. ' ************************************************
  18. Sub WaitTill(next_time As Long)
  19.     Do
  20.         DoEvents
  21.     Loop While GetTickCount() < next_time
  22. End Sub
  23.  
  24.  
  25. ' ************************************************
  26. ' Make sure we should be running. Then start the
  27. ' main form.
  28. ' ************************************************
  29. Sub Main()
  30.     ' Don't start if another instance is already
  31.     ' running.
  32.     If App.PrevInstance Then End
  33.     
  34.     ' If this is a configuration run, do nothing.
  35.     If Command$ = "/c" Then End
  36.  
  37.     ' If this is not a screen saver run, do nothing.
  38.     ' Comment this line out for test runs.
  39. '    If Command$ <> "/s" Then End
  40.  
  41.     ' Move the cursor off the screen.
  42.     SetCursorPos Screen.Width, Screen.Height
  43.  
  44.     ' Show the main form.
  45.     BounceForm.Show
  46. End Sub
  47.  
  48.  
  49.