Screensaver Tutorial *UPDATED* (Again)
This article is for you who struggle to find out how to create a screensaver with vb. This article is an update to my last one. This one includes a working source code example. I have updated this yet again. This one ends on mouse movements. Please vote for me.
Original Author: Person82484536536578579365897
Code
Screensaver Tutorial In this tutorial you will learn how to create a We will create a screensaver today To start off, start a new project in visual basic. Name the project “Blanker”. Add four forms and name one ‘frmMain', one Click the menu project|Blanker Properties. In the ‘General' tab, change the ‘Startup Object' Now In Option 'Constants Public Private ‘API's ‘This Declare ‘This Declare Now copy the main sub: Sub ‘This ‘This Select Case frmSettings.Show Case runScreensaver Case frmPassSetup.Show Case ‘The End End End Now copy the other Private checkInstance ShowCursor 'load Load frmMain.Show End Private 'If If 'check If 'Set 'us frmMain.Caption End Sub ShowCursor End End Now for the Settings Set the form's Property Setting Border Style 4 – Caption About Now just add a label and That form had no code. Now let's move on to the Set the caption to Now add a label that Now copy this code: Private Unload End Private SaveSetting Unload End Now let's get into the Set the form's settings Now add the same Now just enter this Private If exitScreensaver Unload Else txtPassword.Text Me.Hide MsgBox Unload End End Private Unload End Now for the main form: Set the form's Property Setting BackColor &H00000000& BorderStyle 0 – None Caption Blanker WindowState 2 - Now add a line control Public Private Line1.X1 Line1.Y1 Line1.X2 Line1.Y2 Timer1.Enabled End Private If frmPassword.Show Else exitScreensaver End End Private If frmPassword.Show Else exitScreensaver End End Private If frmPassword.Show Else exitScreensaver End End Private If frmPassword.Show Else exitScreensaver End End Private If frmPassword.Show Else exitScreensaver End End Private ShowCursor bWhite End Private If frmPassword.Show Else exitScreensaver End End Private Static Static style="mso-spacerun: yes"> ' Do nothing except in screen saver mode. style="mso-spacerun: yes"> If RunMode <> rmScreenSaver Then style="mso-spacerun: yes"> ' style="mso-spacerun: yes"> If ((x0 = 0) And (y0 = 0)) Or _ style="mso-spacerun: yes"> ((Abs(x0 - X) < 5) And (Abs(y0 - Y) style="mso-spacerun: yes"> Then style="mso-spacerun: yes"> ' It's a small movement. style="mso-spacerun: yes"> x0 = X style="mso-spacerun: yes"> y0 = Y style="mso-spacerun: yes"> Exit Sub style="mso-spacerun: yes"> End If exitScreensaver End Private If frmPassword.Show Else exitScreensaver End End Private Line1.BorderWidth If Line1.BorderWidth If Line1.BorderColor bWhite GoTo End If Line1.BorderColor bWhite End End This: End style='font-weight:normal'>Don't forget: Compile and then change extention style='font-weight:normal'>Now my tutorial ends on making screen savers. If you style='font-size:11.0pt;mso-bidi-font-size:12.0pt'>Edited By: Aaron Lindsay Now style='font-size:11.0pt;mso-bidi-font-size:12.0pt'>Created By: Aaron Lindsay Of style='font-size:11.0pt;mso-bidi-font-size:12.0pt'>Friday, March 30, 2002 style='font-size:11.0pt;mso-bidi-font-size:12.0pt'>Please Vote style='font-size:11.0pt;mso-bidi-font-size:12.0pt'> Note: When Note #2: This was created in VB6. There is no guarantee Note #3: If you're making your own screensaver based on
screensaver with visual basic. It is
fairly easy once you study it so now lets get into the project.
‘frmSettings', one ‘frmPassSetup' and one ‘frmPassword'. Also add a new module.
to Sub Main.Choose the ‘Make' tab and in the title
text box, type “SCRNSAVER Blanker”
click ok and you're ready to start coding!
the module you created, copy these API's into it:
Explicit 'All variables must be declared
Const SW_SHOWNORMAL = 1
Const APP_NAME = "Blanker"
Function Shows and hides the cursor.
Function ShowCursor Lib "user32" (ByVal bShowstyle="mso-spacerun: yes"> As Long) As Long
function finds if another instance of the saver is running.
Function FindWindow Lib "user32" Alias
"FindWindowA"(ByVallpClassName As String, ByVal lpWindowName As
String) As Long
clear=all style='page-break-before:always'>
Main ()
sub is called when windows wants the screensaver to run a certain event.
locates what windows wants and activates it.
Case Mid(UCase$(Trim$(Command$)), 1, 2)
"/C" 'Configurations mode called
1
"", "/S" 'Screensaver mode
"/A" 'Password protect dialog
1
"/P" 'Preview mode
preview mode is very advanced. It is when you see a clip of it on the little
‘monitor. Just leave the monitor screen blank.
Select
Sub
functions that go into the module:
Sub runScreensaver() 'Run the screen saver
'Make sure no other instances are running
False 'Disable cursor
Screen Saver's main form
frmMain
Sub
Sub checkInstance()
no previous instance is running, exit sub
Not App.PrevInstance Then Exit Sub
for another instance of screen saver
FindWindow(vbNullString, APP_NAME) Then Exit Sub
our caption so other instances can find
in the previous line.
= APP_NAME
Sub
exitScreensaver() 'Exit the screensaver
True ‘Show the cursor
Sub
form.
properties as follows:
FixedToolWindow
set it's caption to “Created By: “ and your name or something.
password setup form.
“Password” and the border style to 4.
says “Password:” and add a text box beside it named txtPassword. Now add two
command buttons with one named “cmdOK” and one named “cmdCancel”. Set the
captions to ‘OK' and ‘Cancel'.
Sub cmdCancel_Click()
Me
Sub
Sub cmdOK_Click()
"Blanker", "Settings", "Password",
txtPassword.Text
Me
Sub
other password form.
as the same as the other password's form's settings.
controls as the password setup form with the same properties.
code:
Sub cmdOK_Click()
txtPassword.Text = GetSetting("Blanker", "Settings",
"Password", "") Then
Me
= ""
"Wrong password! Try again!", vbOKOnly + vbCritical,
"Password"
Me
If
Sub
Sub cmdCancel_Click()
Me
Sub
properties as so:
Maximized
anywhere on the form and set it's BorderColor to &H00FFFFFF&. Now just
copy this code and your screensaver will be finished.
bWhite As Boolean
Sub Form_Activate()
= frmMain.Width 2
= frmMain.Height 2
= frmMain.Width 2
= frmMain.Height 2
= True
Sub
Sub Form_Click()
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Form_DblClick()
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Form_KeyPress(KeyAscii As Integer)
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Form_Load()
False 'Hide the cursor
= True
Sub
Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As
Single)
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
Single)
x0 As Integer
y0 As Integer
Exit Sub
Unload on large mouse movements.
< 5)) _
Sub
Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
GetSetting("Blanker", "Settings", "Password",
"") <> "" Then
'If a password is set then show the password box
'exit the screensaver
If
Sub
Sub Timer1_Timer()
= Line1.BorderWidth + 3 'Increase the border width by 3
Line1.BorderWidth >= 1000 Then
= 1 'If the line's border width gets bigger than the screen then set it back to
one.
bWhite = True Then
= vbGreen
= False
This
If
bWhite = False Then
= vbWhite
= True
If
If
Sub
to.scr.
need further instructions because you did not understand, then check the source
code that came with this tutorial.
The Age Of Eleven
The Age Of Ten
testing the screensaver from visual basic, don't use the shortcut of F5 to
start it because it will instantly disappear. Click on the ‘>' part.
that it will work on other versions (It won't work on VB4 16 bit version &
lower).
this tutorial, change all the ‘Blanker's to the name of your choice.
About this post
Posted: 2002-06-01
By: ArchiveBot
Viewed: 90 times
Categories
Attachments
Screensave741784212002.zip
Posted: 9/3/2020 3:45:00 PM
Size: 21,826 bytes
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.