Tools Links Login

Activate the Screensaver

This lesson will show you how to launch the screensaver with code. It's very simple and only takes a couple of lines of code to accomplish. The first part goes in a module.

Original Author: Faisal Arif

Code


(General) (Declarations)
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As _
Long, ByVal lParam As Long) As Long
Public Const WM_SYSCOMMAND = &H112&
Public Const SC_SCREENSAVE = &HF140&
To actually activate the screensaver only takes one line of code. You can put it anywhere you want, but for my example, I'm placing it in the Click event of a command button.
Command1 Click
Private Sub Command1_Click()
Call SendMessage(Me.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, _
  0&)
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 89 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.