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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to know if the Screen Saver is Active

Status
Not open for further replies.

epoirier

Programmer
Feb 22, 2002
37
CA
I try to find something to know if the screen saver is active or not, maybe some code exist in Windows API. Anybody have information about this, i need this code to prevent popup message when the screen saver is activated because the user need to press ALT-TAB to re-activate the form msgbox.


Thanks,

Eric
 
This may be no help but, the following activates / deactivates screen saver. Can't take credit for this as it's not my code, I just know that it works !!!!
I know it's not exactly what you asked for but may point you in the right direction.


'To switch the screen saver on and off use the following code:

Private Const SC_SCREENSAVE = &HF140&
Private Const WM_SYSCOMMAND = &H112
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

'Purpose : Changes the state of the screen saver
'Inputs : bScreenSaver If True, starts the Screen Saver
' else turns the Screen Saver off
' [lHwnd] VB: The form handle OR
' [sFormCaption] VBA: The caption of the form calling the
' routine, can be Me.Caption or Application.Caption

Sub ScreenSaver(bScreenSaver As Boolean, Optional lHwnd As Long, Optional sFormCaption As String)
Dim lState As Long
If lHwnd = 0 Then
lHwnd = FindWindowA(vbNullString, sFormCaption)
End If
If bScreenSaver Then
lState = 1
Else
lState = -1
End If
Call SendMessage(lHwnd, WM_SYSCOMMAND, SC_SCREENSAVE, lState)
End Sub


 
Thanks GHolden, is not what i'm searching but, i can use to desactivate the screen saver when a receive a new message, it's work great.

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top