Screensavers: intercept screen shutdown events
Blitz3D Forums/Blitz3D Programming/Screensavers: intercept screen shutdown events
| ||
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 |
| ||
Well, I have a more concrete example:Const WM_LBUTTONDOWN = $0201 Global w_message.MSG = New MSG Type MSG Field hwnd Field message Field wParam Field lParam Field time$ Field pt.POINT End Type Type POINT Field x Field y End Type While Not KeyDown(1) While api_PeekMessage(w_message,0,0,0,1) Select w_message\message Case WM_LBUTTONDOWN: Print("WM_LBUTTONDOWN") Default: api_DefWindowProc(w_message\hwnd,w_message\message,w_message\lParam,w_message\wParam) End Select Wend Wend End With the following user decl: .lib "user32.dll" api_PeekMessage% (lpMsg*, hwnd%, wMsgFilterMin%, wMsgFilterMax%, wRemoveMsg%) : "PeekMessageA" api_DefWindowProc% (hwnd%, wMsg%, wParam%, lParam%) : "DefWindowProcA" When I run this program, I have to click 5 or 6 times on the left mouse button before receiving a bulk of 5-6 events.... How can I "flush" the events, so exactly each time I press on the mouse button, I receive the event? |