PDA

Click to See Complete Forum and Search --> : Starting a screensaver


SteveCRM
Jan 26th, 2000, 05:35 AM
I was wondering if I could start the screensaver through code. (better than setting it to one minute!)


Steve

chrisjk
Jan 26th, 2000, 08:38 AM
Try this:


Declare Function GetDesktopWindow Lib "user32" () As Long
Private 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 As Long = &H112&
Public Const SC_SCREENSAVE As Long = &HF140&

Sub Main()

Dim hWnd&
On Error Resume Next
hWnd& = GetDesktopWindow()
Call SendMessage(hWnd&, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
End

End Sub


Paste it to the declarations section of a module. You don't need any forms or any other modules for this to work.

All the best,

------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)