Screensavers: intercept screen shutdown events

Blitz3D Forums/Blitz3D Programming/Screensavers: intercept screen shutdown events

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm doing some screensavers in blitz3D.

Everything is working well, but I have one last issue to solve:

Let's say the computer has the following settings:
- Start screensaver after 5 minutes.
- Shutdown screen after 15 minutes.

So my screensaver runs after 5 minutes, then I wait 10 minutes more and the screen goes off.

If I go back to my computer and move the mouse or press a key, the screen turns on and I have my Blitz screensaver still running minimized on the taskbar.

How can I receive this "screen shutdown" event on my Blitz program?

I tried the code from Code Archive (screensaver code: http://www.blitzbasic.com/codearcs/codearcs.php?code=2093 )

in particular the event handler:
			Select w_message\message
				Case WM_DESTROY:
					api_PostQuitMessage(0)
				Case WM_CLOSE:
					ExitScreensaver()
				Case WM_MOUSEMOVE:
					pt.POINT = New POINT
					api_GetCursorPos(pt)
					If Abs(pt\x-orig_pt\x)>10 Or Abs(pt\y-orig_pt\y)>10 Then 
						api_PostMessage(w_message\hwnd,WM_CLOSE,0,0)
					EndIf
				Case WM_LBUTTONDOWN, WM_RBUTTONDOWN, WM_MBUTTONDOWN, WM_KEYDOWN, WM_SYSKEYDOWN:
					api_PostMessage(w_message\hwnd,WM_CLOSE,0,0) 
				Default:
					api_DefWindowProc(w_message\hwnd,w_message\message,w_message\lParam,w_message\wParam)						
			End Select	



but it seems it is not working well on my Vista and XP box.

Any advice of the screensavers gurus out there?

thanks