'Author: Waty Thierry
'Origin: [B]Lien supprimé[/B]
'Purpose: Activate/Deactivate the Screen Saver
'Version: VB4+
Option Explicit
Private Const SPI_SETSCREENSAVEACTIVE = 17
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SENDWININICHANGE = &H2
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Function ToggleScreenSaverActive(Active As Boolean) As Boolean
'To Activate Screen Saver, set active to true
'to deactivate, set active to false
Dim lActiveFlag As Long
Dim retval As Long
lActiveFlag = IIf(Active, 1, 0)
retval = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, lActiveFlag, 0, 0)
ToggleScreenSaverActive = retval > 0
End Function
Private Sub UserForm_Initialize()
ToggleScreenSaverActive False
End Sub
Private Sub UserForm_Terminate()
ToggleScreenSaverActive True
End Sub