home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Screensave741784212002.psc / Module1.bas < prev    next >
Encoding:
BASIC Source File  |  2002-03-23  |  1.6 KB  |  58 lines

  1. Attribute VB_Name = "Module1"
  2. Option Explicit 'All variables must be declared
  3. 'Constants
  4. Public Const SW_SHOWNORMAL = 1
  5. Private Const APP_NAME = "Blanker"
  6. 'API's
  7. 'This Function Shows and hides the cursor.
  8. Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
  9. 'This function finds if another instance of the saver is running.
  10. Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVallpClassName As String, ByVal lpWindowName As String) As Long
  11.  
  12. Sub Main()
  13. 'This sub is called when windows wants the screensaver to run a certain event.
  14. 'This locates what windows wants and activates it.
  15. Select Case Mid(UCase$(Trim$(Command$)), 1, 2)
  16.  
  17. Case "/C" 'Configurations mode called
  18. frmSettings.Show 1
  19.  
  20. Case "", "/S" 'Screensaver mode
  21. runScreensaver
  22.  
  23. Case "/A" 'Password protect dialog
  24. frmPassSetup.Show 1
  25. Case "/P" 'Preview mode
  26. 'The preview mode is very advanced. It is when you see a clip of it on the little 'monitor. Just leave the monitor screen blank.
  27. End
  28. End Select
  29. End Sub
  30.  
  31. Private Sub runScreensaver() 'Run the screen saver
  32. checkInstance 'Make sure no other instances are running
  33. ShowCursor False 'Disable cursor
  34. 'load Screen Saver's main form
  35. Load frmMain
  36. frmMain.Show
  37. End Sub
  38.  
  39.  
  40. Private Sub checkInstance()
  41. 'If no previous instance is running, exit sub
  42. If Not App.PrevInstance Then Exit Sub
  43.  
  44. 'check for another instance of screen saver
  45. If FindWindow(vbNullString, APP_NAME) Then Exit Sub
  46.  
  47. 'Set our caption so other instances can find
  48. 'us in the previous line.
  49.  
  50. frmMain.Caption = APP_NAME
  51. End Sub
  52.  
  53. Sub exitScreensaver() 'Exit the screensaver
  54. ShowCursor True 'Show the cursor
  55. End
  56. End Sub
  57.  
  58.