Code archives/User Input/Confine Cursor
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
*Needs USER32 dll* Use 'Boiled Sweets' User32 Decls http://www.blitzbasic.com/codearcs/codearcs.php?code=1179 Thanks Boiled Sweets. | |||||
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 Left\Top\Right\Bottom. ; 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
| ||
;Example: Graphics 640,480,24,2 ConfineCursor(10,10,20,20) WaitKey() ConfineCursor(0,0,1260,1024) End |
Code Archives Forum