Mouse Outside Window

BlitzPlus Forums/BlitzPlus Programming/Mouse Outside Window

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.

Graphics 640,480,16,2

Const UPS=60

period=1000/UPS
time=MilliSecs()-period

Type TPoint
	Field X%
	Field Y%
End Type


Const VK_LBUTTON = 1
Const VK_RBUTTON = 2
Const VK_MBUTTON = 4

Global cPos.TPoint = New TPoint

Repeat
	Repeat
		elapsed=MilliSecs()-time
	Until elapsed	
	ticks=elapsed/period
	tween#=Float(elapsed Mod period)/Float(period)
	
	For k=1 To ticks
		time=time+period	
		If KeyHit(1) End	
	Next
	
	;get mouse position
	api_GetCursorPos(cPos)
	
	Text 10,10,cPos\X + ", " + cPos\Y
	
	If (api_GetAsyncKeyState(VK_LBUTTON) <> 0)
		Text 10,25, "Left button down"
	EndIf
	
	If (api_GetAsyncKeyState(VK_RBUTTON) <> 0)
		Text 10,25, "Right button down"
	EndIf
	
	If (api_GetAsyncKeyState(VK_MBUTTON) <> 0)
		Text 10,25, "Middle button down"
	EndIf
	
	Flip
	Cls
Forever