|
-
May 15th, 2001, 01:52 PM
#1
Thread Starter
Addicted Member
starting screensaver in win98
i'm having troubles when i'm trying to start the screensaver in Windows98!!!!
this is my code :
Code:
Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal _
wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_SYSCOMMAND As Long = &H112&
Public Const SC_SCREENSAVE As Long = &HF140&
Private Const SPI_SCREENSAVERRUNNING = 97&
Function gf_StartScreenSaver() As Boolean
Dim hwnd&
Dim iNumber As Integer
On Error Resume Next
hwnd& = GetDesktopWindow()
Call SendMessage(hwnd&, WM_SYSCOMMAND, SPI_SCREENSAVERRUNNING, 0&)
iNumber = Err.Number
gf_StartScreenSaver = (Err.Number = 0)
If iNumber = 0 Then boScreenSaverStarted = True
End Function
someone already told me to use the SPI_SCREENSAVERRUNNING variable, but it is still not working.
who knows what i have to do????
-
May 15th, 2001, 01:59 PM
#2
Thread Starter
Addicted Member
i think i might have found an answer myself:
Code:
How to Start a Screen Saver using the API
The sample code below shows how to start a Visual Basic screen saver by sending a Windows message to the Control-menu box on a form.
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.
Declarations
#If Win32 Then
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
Const WM_SYSCOMMAND = &H112&
Const SC_SCREENSAVE = &HF140&
#Else
Private Declare Function SendMessage Lib "User" _
(ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal _
wParam As Integer, lParam As Any) As Long
Const WM_SYSCOMMAND = &H112
Const SC_SCREENSAVE = &HF140&
#End If
Code
To start the screen saver, use the following code:
Dim result As Long
result = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|