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 / vbpg32 / samples4 / ch05 / rectplay.bas < prev    next >
Encoding:
BASIC Source File  |  1996-02-16  |  3.4 KB  |  91 lines

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