Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I turn on the windows screen saver?

API

How can I turn on the windows screen saver?

by  Michael42  Posted    (Edited  )
Microsoft Windows starts screen savers through the System-menu box on a form. The System-menu box is also known as the Control-menu box in Visual Basic. You can send Windows messages to the Control-menu box by using the SendMessage Windows API (application programming interface) function.

Add the following to the general declarations section of Form1, or to
a .Bas module file, in Visual Basic:

' The following Declare statement must be on one, single line:
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer,
ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Long

In the following example, a command button starts the Form1 screen saver:

Sub Command1_Click ()
Dim result As Long
Const WM_SYSCOMMAND = &H112

Const SC_SCREENSAVE = &HF140
result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
End Sub

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top