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 / samples5 / ch09 / puzzle.bas < prev    next >
Encoding:
BASIC Source File  |  1997-02-16  |  5.9 KB  |  171 lines

  1. Attribute VB_Name = "PUZZLE1"
  2. '--------------------------------------------------
  3. '
  4. '           Public Constants
  5. '
  6. Option Explicit
  7. ' Copyright ⌐ 1997 by Desaware Inc. All Rights Reserved
  8.  
  9. Type RECT
  10.         Left As Long
  11.         Top As Long
  12.         Right As Long
  13.         Bottom As Long
  14. End Type
  15.  
  16. Type BITMAPINFOHEADER '40 bytes
  17.         biSize As Long
  18.         biWidth As Long
  19.         biHeight As Long
  20.         biPlanes As Integer
  21.         biBitCount As Integer
  22.         biCompression As Long
  23.         biSizeImage As Long
  24.         biXPelsPerMeter As Long
  25.         biYPelsPerMeter As Long
  26.         biClrUsed As Long
  27.         biClrImportant As Long
  28. End Type
  29.  
  30. Type RGBQUAD
  31.         rgbBlue As Byte
  32.         rgbGreen As Byte
  33.         rgbRed As Byte
  34.         rgbReserved As Byte
  35. End Type
  36.  
  37. Type BITMAPINFO
  38.         bmiHeader As BITMAPINFOHEADER
  39.         bmiColors(16) As RGBQUAD
  40. End Type
  41.  
  42. Type BITMAP
  43.         bmType As Long
  44.         bmWidth As Long
  45.         bmHeight As Long
  46.         bmWidthBytes As Long
  47.         bmPlanes As Integer
  48.         bmBitsPixel As Integer
  49.         bmBits As Long
  50. End Type
  51.  
  52. Type POINTAPI
  53.         x As Long
  54.         y As Long
  55. End Type
  56.  
  57. '----------------------------------------------
  58. '
  59. '       Public Variables
  60. '
  61. ' Bitmap segment location in each puzzle area
  62. ' This represents a 5x5 square array
  63. ' The index represents the position on picture1
  64. ' The entry for each index indicates the number of the
  65. ' tile in the bitmap to place in position index.
  66. Public Position%(24)
  67.  
  68. Public PuzzleRect As RECT
  69.  
  70. Public ShadowDC&
  71. Public BMinfo As BITMAP
  72.  
  73. Public DestRects(24) As RECT
  74. Public SourceRects(24) As RECT
  75.  
  76. ' A flag set by the Puzzle2 form to let the Puzzle form
  77. ' know that a new bitmap was loaded.
  78. Public DoTheUpdate%
  79.  
  80. ' A random brush used for the empty square
  81. Public EmptySquareBrush&
  82.  
  83. ' The mode of the empty square.
  84. ' 0 = black, 1 = white, 2 = use EmptySquareBrush
  85. Public EmptySquareMode%
  86.  
  87.  
  88. Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
  89. Declare Function GetObjectAPI& Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any)
  90. Declare Function CreateDIBitmap Lib "gdi32" (ByVal hdc As Long, lpInfoHeader As BITMAPINFOHEADER, ByVal dwUsage As Long, lpInitBits As Any, lpInitInfo As BITMAPINFO, ByVal wUsage As Long) As Long
  91. Declare Function CreateDIBPatternBrush Lib "gdi32" (ByVal hPackedDIB As Long, ByVal wUsage As Long) As Long
  92. Declare Function CreateDIBPatternBrushPt Lib "gdi32" (lpPackedDIB As Any, ByVal iUsage As Long) As Long
  93. Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
  94. Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  95. Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  96. Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  97. Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
  98. Declare Function PatBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long) As Long
  99. Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long
  100. Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  101. Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
  102.  
  103.  
  104. Public Const CBM_INIT = &H4&    '  initialize bitmap
  105. Public Const DIB_RGB_COLORS = 0 '  color table in RGBTriples
  106. Public Const DIB_PAL_COLORS = 1 '  color table in palette indices
  107.  
  108. Public Const OBM_CLOSE = 32754
  109. Public Const OBM_UPARROW = 32753
  110. Public Const OBM_DNARROW = 32752
  111. Public Const OBM_RGARROW = 32751
  112. Public Const OBM_LFARROW = 32750
  113. Public Const OBM_REDUCE = 32749
  114. Public Const OBM_ZOOM = 32748
  115. Public Const OBM_RESTORE = 32747
  116. Public Const OBM_REDUCED = 32746
  117. Public Const OBM_ZOOMD = 32745
  118. Public Const OBM_RESTORED = 32744
  119. Public Const OBM_UPARROWD = 32743
  120. Public Const OBM_DNARROWD = 32742
  121. Public Const OBM_RGARROWD = 32741
  122. Public Const OBM_LFARROWD = 32740
  123. Public Const OBM_MNARROW = 32739
  124. Public Const OBM_COMBO = 32738
  125. Public Const OBM_UPARROWI = 32737
  126. Public Const OBM_DNARROWI = 32736
  127. Public Const OBM_RGARROWI = 32735
  128. Public Const OBM_LFARROWI = 32734
  129. Public Const OBM_OLD_CLOSE = 32767
  130. Public Const OBM_SIZE = 32766
  131. Public Const OBM_OLD_UPARROW = 32765
  132. Public Const OBM_OLD_DNARROW = 32764
  133. Public Const OBM_OLD_RGARROW = 32763
  134. Public Const OBM_OLD_LFARROW = 32762
  135. Public Const OBM_BTSIZE = 32761
  136. Public Const OBM_CHECK = 32760
  137. Public Const OBM_CHECKBOXES = 32759
  138. Public Const OBM_BTNCORNERS = 32758
  139. Public Const OBM_OLD_REDUCE = 32757
  140. Public Const OBM_OLD_ZOOM = 32756
  141. Public Const OBM_OLD_RESTORE = 32755
  142. Public Const OIC_SAMPLE = 32512
  143. Public Const OIC_HAND = 32513
  144. Public Const OIC_QUES = 32514
  145. Public Const OIC_BANG = 32515
  146. Public Const OIC_NOTE = 32516
  147. Public Const SRCCOPY = &HCC0020
  148. Public Const SRCPAINT = &HEE0086
  149. Public Const SRCAND = &H8800C6
  150. Public Const SRCINVERT = &H660046
  151. Public Const SRCERASE = &H440328
  152. Public Const NOTSRCCOPY = &H330008
  153. Public Const NOTSRCERASE = &H1100A6
  154. Public Const MERGECOPY = &HC000CA
  155. Public Const MERGEPAINT = &HBB0226
  156. Public Const PATCOPY = &HF00021
  157. Public Const PATPAINT = &HFB0A09
  158. Public Const PATINVERT = &H5A0049
  159. Public Const DSTINVERT = &H550009
  160. Public Const BLACKNESS = &H42&
  161. Public Const WHITENESS = &HFF0062
  162. Public Const BLACKONWHITE = 1
  163. Public Const WHITEONBLACK = 2
  164. Public Const COLORONCOLOR = 3
  165. Public Const BI_RGB = 0&
  166. Public Const BI_RLE8 = 1&
  167. Public Const BI_RLE4 = 2&
  168. Public Const TRANSPARENT = 1
  169. Public Const OPAQUE = 2
  170.  
  171.