Screensavers: intercept screen shutdown events

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

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?