This Zip file also contains a Blank Screen screen saver already made as a sample. You can just use that one as a template, or make one from scratch by following the instructions below.
Create a new project with two forms (frmSS and frmConfig) and one module(mdlSubMain), and set the project's Startup Object to Sub Main. Add this code to mdlSubMain:
Option Explicit Public Sub Main() If App.PrevInstance = True Then End 'Exit if the SS is already running. If Left(Command$, 1) = "s" Or Right(Left(Command$, 2), 1) = "s" Then frmSS.Show vbModal 'If the first or second character is "s" then show frmSS. ElseIf Left(Command$, 1) = "c" Or Right(Left(Command$, 2), 1) = "c" Then frmConfig.Show vbModal 'If the first or second character is "c" then show frmConfig. ElseIf Left(Command$, 1) = "a" Or Right(Left(Command$, 2), 1) = "a" Then MsgBox "No password protection is available." 'If the first or second character is "a" then show a message box telling the user there's no password protection. ElseIf Left(Command$, 1) = "p" Or Right(Left(Command$, 2), 1) = "p" Then End 'If the first or second character is "p" then end the program. End If End Sub
Make frmSS a black, borderless form with a maximized window state, and add this code to it:
Option Explicit Private Declare Function ShowCursor Lib "User32" (ByVal Show As Integer) As Integer 'Declare the API to show/hide the mouse pointer. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Static Count As Integer: Count = Count + 1: If Count > 2 Then End 'On the fourth key press exit the SS. End Sub Private Sub Form_Load() ShowCursor 0 'Hide the mouse pointer. End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Static Count As Integer: Count = Count + 1: If Count > 2 Then End 'On the fourth mouse button press exit the SS. End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Static Count As Integer: Count = Count + 1: If Count > 2 Then End 'On the fourth mouse movement exit the SS. End Sub
If you want to expand the screen saver, then you can add a timer to frmSS and set it to draw to the form, move images around and so on, just as you could in any other program. Be careful of making the screen saver to complicated, as it should be able to load and unload quickly.
It is up to you what you do with frmConfig; you can either display an about box with a "no settings are available" message (as I have done in the sample Blank Screen screen saver) or add some controls to set properties to the registry (using SaveSetting) which can be loaded into the screen saver later (using LoadSetting).
Because of the way the screen saver is set up, you can't test it by using the Run button in Visual Basic. Instead, you must compile it to the C:\Windows folder with a .scr extension (instead of a .exe extension) and then activate it using the Desktop settings in Control Panel. Try out the preview, settings and password buttons to check if they work.
If you have any problems or comments, use the feedback facility on PSC or Email me (below). I am interested if anyone knows how to make a preview appear in the monitor in the Control Panel screen saver dialog, or add password protection (which can be deactivated using the check box in the dialog). I am currently working on a tutorial about making screen savers using DirectX 7, and suggestions would be welcomed.
--Tom Walker
Email: tomwalker@hotmail.com