home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / classlib / classact / rectplay.bas < prev    next >
Encoding:
BASIC Source File  |  1996-01-22  |  3.5 KB  |  90 lines

  1. Attribute VB_Name = "RECTPLAY1"
  2. Option Explicit
  3.  
  4. ' Rectplay
  5. '
  6. ' Chapter 5 demonstration of rectangle operations
  7.  
  8. '--------------------------------------------------------
  9. '
  10. '                   API Declarations
  11. '
  12. '-------------------------------------------------------
  13.  
  14. #If Win32 Then
  15. ' 32 Bit declarations
  16. 'Type RECT
  17. '        left As Long
  18. '        top As Long
  19. '        right As Long
  20. '        bottom As Long
  21. 'End Type
  22. '
  23. 'Type POINTAPI
  24. '        X As Long
  25. '        Y As Long
  26. 'End Type
  27. '
  28. 'Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  29. 'Declare Function SetRectEmpty Lib "user32" (lpRect As RECT) As Long
  30. 'Declare Function CopyRect Lib "user32" (lpDestRect As RECT, lpSourceRect As RECT) As Long
  31. 'Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long
  32. 'Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
  33. 'Declare Function UnionRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
  34. 'Declare Function SubtractRect Lib "user32" (lprcDst As RECT, lprcSrc1 As RECT, lprcSrc2 As RECT) As Long
  35. 'Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long
  36. 'Declare Function IsRectEmpty Lib "user32" (lpRect As RECT) As Long
  37. 'Declare Function EqualRect Lib "user32" (lpRect1 As RECT, lpRect2 As RECT) As Long
  38. 'Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
  39.  
  40. #Else
  41. ' 16 bit declarations
  42. 'Type RECT
  43. '    left As Integer
  44. '    top As Integer
  45. '    right As Integer
  46. '    bottom As Integer
  47. 'End Type
  48. '
  49. 'Type POINTAPI
  50. '    X As Integer
  51. '    Y As Integer
  52. 'End Type
  53. '
  54. 'Declare Sub SetRect Lib "User" (lpRect As RECT, ByVal X1 As Integer, ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer)
  55. 'Declare Sub SetRectEmpty Lib "User" (lpRect As RECT)
  56. 'Declare Function CopyRect Lib "User" (lpDestRect As RECT, lpSourceRect As RECT) As Integer
  57. 'Declare Sub InflateRect Lib "User" (lpRect As RECT, ByVal X As Integer, ByVal Y As Integer)
  58. 'Declare Function IntersectRect Lib "User" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Integer
  59. 'Declare Function UnionRect Lib "User" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Integer
  60. 'Declare Sub OffsetRect Lib "User" (lpRect As RECT, ByVal X As Integer, ByVal Y As Integer)
  61. 'Declare Function IsRectEmpty Lib "User" (lpRect As RECT) As Integer
  62. 'Declare Function EqualRect Lib "User" (lpRect1 As RECT, lpRect2 As RECT) As Integer
  63. 'Declare Function PtInRect Lib "User" (lpRect As RECT, ByVal pty As Integer, ByVal ptx As Integer) As Integer
  64. 'Declare Function PtInRectByNum Lib "User" Alias "PtInRect" (lpRect As RECT, ByVal ptRect As Long) As Integer
  65.  
  66. #End If
  67.  
  68.  
  69. '--------------------------------------------------------
  70. '
  71. '                   Application Globals
  72. '
  73. '-------------------------------------------------------
  74.  
  75. ' Global rectangles
  76.  
  77. Global Rect1 As New foRectangle          'RECT
  78. Global Rect2 As New foRectangle          'RECT
  79. Global RectUnion As New foRectangle      'RECT
  80. Global RectIntersect As New foRectangle  'RECT
  81.  
  82. Global SettingState%    ' 0 = Point detect mode
  83.                         ' 1 = Setting rect1
  84.                         ' 2 = Setting rect2
  85.  
  86. Global StartPoint As New foPoint    'POINTAPI
  87. Global EndPoint As New foPoint      'POINTAPI
  88. Global HasCapture%  ' Indicates that tracking is in effect
  89.  
  90.