February 28, 2021
Hot Topics:

Quickstart Guide to Screensavers

  • By Karl Moore
  • Send Email »
  • More Articles »

Your actual screensaver needs to be able to handle user responses. When the mouse moves, it needs to quit or prompt for a password. The cursor should be invisible and the task keys should be disabled. This section handles these issues.

Hiding the Cursor

  • Add the following API declaration to a module in your screensaver application:
Declare Function ShowCursor Lib "user32" _    (ByVal bShow As Long) As Long
  • Pass the ShowCursor API call a True or False to show or hide the cursor, respectively. For example, this code hides the cursor: Call ShowCursor(False)

Disabling Task Keys

Task key combinations, such as CTRL-ALT-DEL, ALT-TAB and CTRL-F4, should be disabled when your screensaver starts, then re-enabled when it quits.

  • Add the following code to a module in your screensaver application:
Private Const SPI_SCREENSAVERRUNNING = 97&Declare Function SystemParametersInfo Lib "user32" _    Alias "SystemParametersInfoA" (ByVal uAction As _    Long, ByVal uParam As Long, lpvParam As Any, ByVal _    fuWinIni As Long) As LongPublic Sub EnableTaskKeys(Enabled As Boolean)If Enabled = False Then    'Disable CTRL+ALT+DELETE    SystemParametersInfo SPI_SCREENSAVERRUNNING, 1&, 0&, 0Else    ' Enable CTRL+ALT+DELETE    SystemParametersInfo SPI_SCREENSAVERRUNNING, 0&, 0&, 0End IfEnd Sub
  • To use this code, run the EnableTaskKeys method, passing a True or False argument to enable or disable the task keys respectively. For example, to enable the task keys, run: EnableTaskKeys (True)

Checking for Mouse Movement

You need to monitor mouse movement in your screensaver, so you know when to either quit or prompt for a password.

  • Add the following code behind the MouseMove event of your Form:
Static intMoveCount As IntegerIntMoveCount = intMoveCount + 1If intMoveCount > 5 Then Unload MyScreenSaverForm

Page 6 of 8

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date