Quickstart Guide to Screensavers, Page 6
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
0 Comments (click to add your comment)
Networking Solutions
