[bb] Confine Cursor by aab [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:41

Previous topic - Next topic

BlitzBot

Title : Confine Cursor
Author : aab
Posted : 1+ years ago

Description : *Needs USER32 dll*
Use 'Boiled Sweets' User32 Decls
<a href="codearcsbcfe.html?code=1179" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=1179</a>
Thanks Boiled Sweets.


Code :
Code (blitzbasic) Select
Function ConfineCursor(x%,y%,w%,h%)
Local r%=(CreateBank(16))
PokeInt(r,0,x%):PokeInt(r,4,y%):PokeInt(r,8,x%+w%):PokeInt(r,12,y%+h%)
api_ClipCursor%(r)
FreeBank(r)
Return(True)
End Function
;this assumes that a long is the size of an int. i cant take responsibility for that.


;the bank is acting as a LPRECT/RECT*. ie Long LeftTopRightBottom.
; PokeInt(r,0,x%):PokeInt(r,4,y%):PokeInt(r,8,x%+w%):PokeInt(r,12,y%+h%)

;knowing this commands such as api_IntersectRect and other Rectanle commands can be addressed this way
;or through a type eg [ Type Rect_ Field L%,T%,R%,B% End Type ].


Comments :


aab(Posted 1+ years ago)

 
;Example:
Graphics 640,480,24,2

ConfineCursor(10,10,20,20)

WaitKey()

ConfineCursor(0,0,1260,1024)

End