November 25, 2020, 08:32:44 AM

Author Topic: [bb] Confine Cursor by aab [ 1+ years ago ]  (Read 586 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Confine Cursor by aab [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
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[/url]
Thanks Boiled Sweets.


Code :
Code: BlitzBasic
  1. Function ConfineCursor(x%,y%,w%,h%)
  2.         Local r%=(CreateBank(16))
  3.                 PokeInt(r,0,x%):PokeInt(r,4,y%):PokeInt(r,8,x%+w%):PokeInt(r,12,y%+h%) 
  4.                 api_ClipCursor%(r)
  5.                 FreeBank(r)
  6.         Return(True)
  7. End Function
  8. ;this assumes that a long is the size of an int. i cant take responsibility for that.
  9.  
  10.  
  11. ;the bank is acting as a LPRECT/RECT*. ie Long LeftTopRightBottom.
  12. ;       PokeInt(r,0,x%):PokeInt(r,4,y%):PokeInt(r,8,x%+w%):PokeInt(r,12,y%+h%)
  13.  
  14. ;knowing this commands such as api_IntersectRect and other Rectanle commands can be addressed this way
  15. ;or through a type eg [ Type Rect_ Field L%,T%,R%,B% End Type ].


Comments :


aab(Posted 1+ years ago)

 
Code: [Select]
;Example:
Graphics 640,480,24,2

ConfineCursor(10,10,20,20)

WaitKey()

ConfineCursor(0,0,1260,1024)

End


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal