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 / desaware / dwhdc.cls < prev    next >
Encoding:
Text File  |  1996-04-23  |  105.6 KB  |  2,559 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "dwDeviceContext"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. ' Class dwDeviceContext
  11. ' Device context object control and configuration class
  12. ' Copyright (c) 1996 by Desaware Inc.
  13. ' Part of the Desaware API Classes Library
  14.  
  15. ' These flags will activate certain functions that require
  16. ' classes that most functions do not need.  If you do not
  17. ' need to use a function that is triggered by a flag, you
  18. ' can set the flag to False, and prevent an unneeded class
  19. ' from being loaded.
  20. #Const FlagBitmap = True ' uses dwBitmap
  21. #Const FlagGetDeviceCaps = True ' uses dwDevCaps
  22. #Const FlagPlayEnhMetaFileRecord = True ' uses dwHandleTable and dwEnhMetaRecord
  23. #Const FlagMetaFile = True ' all functions that use dwMetafile
  24.  
  25. ' A number of functions require a group of data in a single
  26. ' parameter.  This task is traditionally handled by an array.
  27. ' Visual Basic 4.0 has a new data type called a Collection.
  28. ' This class library uses Collections, but if you prefer
  29. ' arrays, or your program uses arrays extensivly, then setting
  30. ' this flag to True will switch those functions to their
  31. ' array-using equivalents.
  32. #Const FlagUseArrayNotCollection = False
  33.  
  34.  
  35. #If Win32 Then
  36. Private iHDC As Long
  37. #Else
  38. Private iHDC As Integer
  39. #End If
  40.  
  41. ' Who owns this DC?
  42. ' 0 - This DC is via GetDC
  43. ' 1 - This DC is via CreateDC or CreateCompatibleDC
  44. ' 2 - This DC is via direct setting
  45. ' 3 - This DC is a regular metafile
  46. ' 4 - This DC is an enhanced metafile
  47. Public DCsource%
  48.  
  49. Public DeviceCaps As New dwDevCaps
  50.  
  51. ' Currently selected objects
  52. Private iCurrentBrush As dwBrush
  53. Private iCurrentPen As dwPen
  54.  
  55. Private OriginalBrush As Long
  56. Private OriginalPen As Long
  57.  
  58. #If FlagBitmap Then
  59. Private OriginalBitmap As Long
  60. Private iCurrentBitmap As dwBitmap
  61. #End If
  62.  
  63. ' InitialSaveDC - On assign or GetDC we do an initial SaveDC
  64. ' to store original VB state. This also makes sure
  65. ' all objects are selected out when we delete/destroy the DC
  66. Private InitialSaveDC As Long
  67.  
  68. ' Which window (if any) owns this device context?
  69. Private objwnd As dwWindow
  70.  
  71.  
  72. '**  Functions Chapter 7 Index
  73.  
  74. #If Win32 Then
  75. Private Declare Function apiCreateCompatibleDC& Lib "gdi32" Alias "CreateCompatibleDC" (ByVal hDC As Long)
  76. Private Declare Function apiCreateDC& Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE)
  77. Private Declare Function apiCreateDCByVal& Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Long)
  78. Private Declare Function apiCreateDCBynum& Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long)
  79. Private Declare Function apiDeleteDC& Lib "gdi32" Alias "DeleteDC" (ByVal hDC As Long)
  80. Private Declare Function apiDPtoLP& Lib "gdi32" Alias "DPtoLP" (ByVal hDC As Long, lpPoint As POINTAPI, ByVal nCount As Long)
  81. Private Declare Function apiExcludeClipRect& Lib "gdi32" Alias "ExcludeClipRect" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long)
  82. Private Declare Function apiExcludeUpdateRgn& Lib "user32" Alias "ExcludeUpdateRgn" (ByVal hDC As Long, ByVal hwnd As Long)
  83. Private Declare Function apiExtSelectClipRgn& Lib "gdi32" Alias "ExtSelectClipRgn" (ByVal hDC As Long, ByVal hRgn As Long, ByVal fnMode As Long)
  84. Private Declare Function apiFillRgn& Lib "gdi32" Alias "FillRgn" (ByVal hDC As Long, ByVal hRgn As Long, ByVal hBrush As Long)
  85. Private Declare Function apiFrameRgn& Lib "gdi32" Alias "FrameRgn" (ByVal hDC As Long, ByVal hRgn As Long, ByVal hBrush As Long, ByVal nWidth As Long, ByVal nHeight As Long)
  86. Private Declare Function apiGetBoundsRect& Lib "gdi32" Alias "GetBoundsRect" (ByVal hDC As Long, lprcBounds As RECT, ByVal Flags As Long)
  87. Private Declare Function apiGetClipBox& Lib "gdi32" Alias "GetClipBox" (ByVal hDC As Long, lpRect As RECT)
  88. Private Declare Function apiGetClipRgn& Lib "gdi32" Alias "GetClipRgn" (ByVal hDC As Long, ByVal hRgn As Long)
  89. Private Declare Function apiGetDCOrgEx& Lib "gdi32" Alias "GetDCOrgEx" (ByVal hDC As Long, lpPoint As POINTAPI)
  90. Private Declare Function apiGetDeviceCaps& Lib "gdi32" Alias "GetDeviceCaps" (ByVal hDC As Long, ByVal nIndex As Long)
  91. Private Declare Function apiGetMapMode& Lib "gdi32" Alias "GetMapMode" (ByVal hDC As Long)
  92. Private Declare Function apiGetRgnBox& Lib "gdi32" Alias "GetRgnBox" (ByVal hRgn As Long, lpRect As RECT)
  93. Private Declare Function apiGetUpdateRgn& Lib "user32" Alias "GetUpdateRgn" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal fErase As Long)
  94. Private Declare Function apiGetViewportExtEx& Lib "gdi32" Alias "GetViewportExtEx" (ByVal hDC As Long, lpSize As SIZE)
  95. Private Declare Function apiGetViewportOrgEx& Lib "gdi32" Alias "GetViewportOrgEx" (ByVal hDC As Long, lpPoint As POINTAPI)
  96. Private Declare Function apiGetWindowDC& Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long)
  97. Private Declare Function apiGetWindowExtEx& Lib "gdi32" Alias "GetWindowExtEx" (ByVal hDC As Long, lpSize As SIZE)
  98. Private Declare Function apiGetWindowOrgEx& Lib "gdi32" Alias "GetWindowOrgEx" (ByVal hDC As Long, lpPoint As POINTAPI)
  99. Private Declare Function apiIntersectClipRect& Lib "gdi32" Alias "IntersectClipRect" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long)
  100. Private Declare Function apiInvertRgn& Lib "gdi32" Alias "InvertRgn" (ByVal hDC As Long, ByVal hRgn As Long)
  101. Private Declare Function apiLPtoDP& Lib "gdi32" Alias "LPtoDP" (ByVal hDC As Long, lpPoint As POINTAPI, ByVal nCount As Long)
  102. Private Declare Function apiOffsetClipRgn& Lib "gdi32" Alias "OffsetClipRgn" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long)
  103. Private Declare Function apiOffsetViewportOrgEx& Lib "gdi32" Alias "OffsetViewportOrgEx" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI)
  104. Private Declare Function apiOffsetWindowOrgEx& Lib "gdi32" Alias "OffsetWindowOrgEx" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI)
  105. Private Declare Function apiPaintRgn& Lib "gdi32" Alias "PaintRgn" (ByVal hDC As Long, ByVal hRgn As Long)
  106. Private Declare Function apiPtVisible& Lib "gdi32" Alias "PtVisible" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long)
  107. Private Declare Function apiRectVisible& Lib "gdi32" Alias "RectVisible" (ByVal hDC As Long, lpRect As RECT)
  108. Private Declare Function apiRestoreDC& Lib "gdi32" Alias "RestoreDC" (ByVal hDC As Long, ByVal nSavedDC As Long)
  109. Private Declare Function apiSaveDC& Lib "gdi32" Alias "SaveDC" (ByVal hDC As Long)
  110. Private Declare Function apiScaleViewportExtEx& Lib "gdi32" Alias "ScaleViewportExtEx" (ByVal hDC As Long, ByVal nXnum As Long, ByVal nXdenom As Long, ByVal nYnum As Long, ByVal nYdenom As Long, lpSize As SIZE)
  111. Private Declare Function apiScaleWindowExtEx& Lib "gdi32" Alias "ScaleWindowExtEx" (ByVal hDC As Long, ByVal nXnum As Long, ByVal nXdenom As Long, ByVal nYnum As Long, ByVal nYdenom As Long, lpSize As SIZE)
  112. Private Declare Function apiScrollDC& Lib "user32" Alias "ScrollDC" (ByVal hDC As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hRgnUpdate As Long, lprcUpdate As RECT)
  113. Private Declare Function apiSelectClipRgn& Lib "gdi32" Alias "SelectClipRgn" (ByVal hDC As Long, ByVal hRgn As Long)
  114. Private Declare Function apiSetBoundsRect& Lib "gdi32" Alias "SetBoundsRect" (ByVal hDC As Long, lprcBounds As RECT, ByVal Flags As Long)
  115. Private Declare Function apiSetMapMode& Lib "gdi32" Alias "SetMapMode" (ByVal hDC As Long, ByVal nMapMode As Long)
  116. Private Declare Function apiSetViewportExtEx& Lib "gdi32" Alias "SetViewportExtEx" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, lpSize As SIZE)
  117. Private Declare Function apiSetViewportOrgEx& Lib "gdi32" Alias "SetViewportOrgEx" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI)
  118. Private Declare Function apiSetWindowExtEx& Lib "gdi32" Alias "SetWindowExtEx" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, lpSize As SIZE)
  119. Private Declare Function apiSetWindowOrgEx& Lib "gdi32" Alias "SetWindowOrgEx" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, lpPoint As POINTAPI)
  120. Private Declare Function apiWindowFromDC& Lib "user32" Alias "WindowFromDC" (ByVal hDC As Long)
  121. #Else
  122. Private Declare Function apiCreateCompatibleDC% Lib "gdi" Alias "CreateCompatibleDC" (ByVal hDC As Integer)
  123. Private Declare Function apiCreateDC% Lib "gdi" Alias "CreateDC" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Long)
  124. Private Declare Function apiCreateDCByVal% Lib "gdi" Alias "CreateDC" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Long)
  125. Private Declare Function apiDeleteDC% Lib "gdi" Alias "DeleteDC" (ByVal hDC As Integer)
  126. Private Declare Function apiDPtoLP% Lib "gdi" Alias "DPtoLP" (ByVal hDC As Integer, lpPoints As POINTAPI, ByVal nCount As Integer)
  127. Private Declare Function apiExcludeClipRect% Lib "gdi" Alias "ExcludeClipRect" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer)
  128. Private Declare Function apiExcludeUpdateRgn% Lib "user" Alias "ExcludeUpdateRgn" (ByVal hDC As Integer, ByVal hwnd As Integer)
  129. 'Function ExtSelectClipRgn is not available in the WIN16 API.
  130. Private Declare Function apiFillRgn% Lib "gdi" Alias "FillRgn" (ByVal hDC As Integer, ByVal hRgn As Integer, ByVal hBrush As Integer)
  131. Private Declare Function apiFrameRgn% Lib "gdi" Alias "FrameRgn" (ByVal hDC As Integer, ByVal hRgn As Integer, ByVal hBrush As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer)
  132. Private Declare Function apiGetBoundsRect% Lib "gdi" Alias "GetBoundsRect" (ByVal hDC As Integer, lprcBounds As RECT, ByVal Flags As Integer)
  133. Private Declare Function apiGetClipBox% Lib "gdi" Alias "GetClipBox" (ByVal hDC As Integer, lpRect As RECT)
  134. 'Function GetClipRgn is not available in the WIN16 API.
  135. 'Function GetDCOrgEx is not available in the WIN16 API.
  136. Private Declare Function apiGetDeviceCaps% Lib "gdi" Alias "GetDeviceCaps" (ByVal hDC As Integer, ByVal nIndex As Integer)
  137. Private Declare Function apiGetMapMode% Lib "gdi" Alias "GetMapMode" (ByVal hDC As Integer)
  138. Private Declare Function apiGetRgnBox% Lib "gdi" Alias "GetRgnBox" (ByVal hRgn As Integer, lpRect As RECT)
  139. Private Declare Function apiGetUpdateRgn% Lib "user" Alias "GetUpdateRgn" (ByVal hwnd As Integer, ByVal hRgn As Integer, ByVal fErase As Integer)
  140. Private Declare Function apiGetViewportExtEx% Lib "gdi" Alias "GetViewportExtEx" (ByVal hDC As Integer, lpSize As SIZE)
  141. Private Declare Function apiGetViewportOrgEx% Lib "gdi" Alias "GetViewportOrgEx" (ByVal hDC As Integer, lpSize As SIZE)
  142. Private Declare Function apiGetWindowDC% Lib "user" Alias "GetWindowDC" (ByVal hwnd As Integer)
  143. Private Declare Function apiGetWindowExtEx% Lib "gdi" Alias "GetWindowExtEx" (ByVal hDC As Integer, lpSize As SIZE)
  144. Private Declare Function apiGetWindowOrgEx% Lib "gdi" Alias "GetWindowOrgEx" (ByVal hDC As Integer, lpSize As SIZE)
  145. Private Declare Function apiIntersectClipRect% Lib "gdi" Alias "IntersectClipRect" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer)
  146. Private Declare Function apiInvertRgn% Lib "gdi" Alias "InvertRgn" (ByVal hDC As Integer, ByVal hRgn As Integer)
  147. Private Declare Function apiLPtoDP% Lib "gdi" Alias "LPtoDP" (ByVal hDC As Integer, lpPoints As POINTAPI, ByVal nCount As Integer)
  148. Private Declare Function apiOffsetClipRgn% Lib "gdi" Alias "OffsetClipRgn" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer)
  149. Private Declare Function apiOffsetViewportOrgEx% Lib "gdi" Alias "OffsetViewportOrgEx" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, lpPoint As POINTAPI)
  150. Private Declare Function apiOffsetWindowOrgEx% Lib "gdi" Alias "OffsetWindowOrgEx" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, lpPoint As POINTAPI)
  151. Private Declare Function apiPaintRgn% Lib "gdi" Alias "PaintRgn" (ByVal hDC As Integer, ByVal hRgn As Integer)
  152. Private Declare Function apiPtVisible% Lib "gdi" Alias "PtVisible" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer)
  153. Private Declare Function apiRectVisible% Lib "gdi" Alias "RectVisible" (ByVal hDC As Integer, lpRect As RECT)
  154. Private Declare Function apiRestoreDC% Lib "gdi" Alias "RestoreDC" (ByVal hDC As Integer, ByVal nSavedDC As Integer)
  155. Private Declare Function apiSaveDC% Lib "gdi" Alias "SaveDC" (ByVal hDC As Integer)
  156. Private Declare Function apiScaleViewportExtEx& Lib "gdi" Alias "ScaleViewportExtEx" (ByVal hDC As Integer, ByVal nXnum As Integer, ByVal nXdenom As Integer, ByVal nYnum As Integer, ByVal nYdenom As Integer, lpSize As SIZE)
  157. Private Declare Function apiScaleWindowExtEx& Lib "gdi" Alias "ScaleWindowExtEx" (ByVal hDC As Integer, ByVal nXnum As Integer, ByVal nXdenom As Integer, ByVal nYnum As Integer, ByVal nYdenom As Integer, lpSize As SIZE)
  158. Private Declare Function apiScrollDC% Lib "user" Alias "ScrollDC" (ByVal hDC As Integer, ByVal dx As Integer, ByVal dy As Integer, lprcScroll As RECT, lprcClip As RECT, ByVal hRgnUpdate As Integer, lprcUpdate As RECT)
  159. Private Declare Function apiSelectClipRgn% Lib "gdi" Alias "SelectClipRgn" (ByVal hDC As Integer, ByVal hRgn As Integer)
  160. Private Declare Function apiSetBoundsRect% Lib "gdi" Alias "SetBoundsRect" (ByVal hDC As Integer, lprcBounds As RECT, ByVal Flags As Integer)
  161. Private Declare Function apiSetMapMode% Lib "gdi" Alias "SetMapMode" (ByVal hDC As Integer, ByVal nMapMode As Integer)
  162. Private Declare Function apiSetViewportExtEx% Lib "gdi" Alias "SetViewportExtEx" (ByVal hDC As Integer, ByVal nX As Integer, ByVal nY As Integer, lpSize As SIZE)
  163. Private Declare Function apiSetViewportOrgEx% Lib "gdi" Alias "SetViewportOrgEx" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, lpSize As SIZE)
  164. Private Declare Function apiSetWindowExtEx% Lib "gdi" Alias "SetWindowExtEx" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, lpSize As SIZE)
  165. Private Declare Function apiSetWindowOrgEx% Lib "gdi" Alias "SetWindowOrgEx" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, lpSize As SIZE)
  166. 'Function WindowFromDC is not available in the WIN16 API.
  167. #End If 'WIN32
  168.  
  169. '**Functions Chapter 8 Reference
  170.  
  171. #If Win32 Then
  172. Private Declare Function apiDrawEdge& Lib "user32" Alias "DrawEdge" (ByVal hDC As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long)
  173. Private Declare Function apiGetBrushOrgEx& Lib "gdi32" Alias "GetBrushOrgEx" (ByVal hDC As Long, lpPoint As POINTAPI)
  174. Private Declare Function apiPaintDesktop Lib "user32" Alias "PaintDesktop" (ByVal hDC As Long)
  175. Private Declare Function apiSelectClipPath& Lib "gdi32" Alias "SelectClipPath" (ByVal hDC As Long, ByVal iMode As Long)
  176. Private Declare Function apiAbortPath& Lib "gdi32" Alias "AbortPath" (ByVal hDC As Long)
  177. Private Declare Function apiAngleArc& Lib "gdi32" Alias "AngleArc" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal dwRadius As Long, ByVal eStartAngle As Double, ByVal eSweepAngle As Double)
  178. Private Declare Function apiArc& Lib "gdi32" Alias "Arc" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long)
  179. Private Declare Function apiArcTo& Lib "gdi32" Alias "ArcTo" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long)
  180. Private Declare Function apiBeginPath& Lib "gdi32" Alias "BeginPath" (ByVal hDC As Long)
  181. Private Declare Function apiCancelDC& Lib "gdi32" Alias "CancelDC" (ByVal hDC As Long)
  182. Private Declare Function apiChord& Lib "gdi32" Alias "Chord" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long)
  183. Private Declare Function apiCloseEnhMetaFile& Lib "gdi32" Alias "CloseEnhMetaFile" (ByVal hDC As Long)
  184. Private Declare Function apiCloseMetaFile& Lib "gdi32" Alias "CloseMetaFile" (ByVal hMF As Long)
  185. Private Declare Function apiCloseFigure& Lib "gdi32" Alias "CloseFigure" (ByVal hDC As Long)
  186. Private Declare Function apiCopyEnhMetaFile& Lib "gdi32" Alias "CopyEnhMetaFileA" (ByVal hemfSrc As Long, ByVal lpszFile As String)
  187. Private Declare Function apiCreateEnhMetaFile& Lib "gdi32" Alias "CreateEnhMetaFileA" (ByVal hdcRef As Long, ByVal lpFileName As String, lpRect As RECT, ByVal lpDescription As String)
  188. Private Declare Function apiDeleteEnhMetaFile& Lib "gdi32" Alias "DeleteEnhMetaFile" (ByVal hemf As Long)
  189. Private Declare Function apiDeleteMetaFile& Lib "gdi32" Alias "DeleteMetaFile" (ByVal hMF As Long)
  190. Private Declare Function apiDeleteObject& Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Long)
  191. Private Declare Function apiDrawEscape& Lib "gdi32" Alias "DrawEscape" (ByVal hDC As Long, ByVal nEscape As Long, ByVal cbInput As Long, ByVal lpszInData As String)
  192. Private Declare Function apiDrawFocusRect& Lib "user32" Alias "DrawFocusRect" (ByVal hDC As Long, lpRect As RECT)
  193. Private Declare Function apiEllipse& Lib "gdi32" Alias "Ellipse" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long)
  194. Private Declare Function apiEndPath& Lib "gdi32" Alias "EndPath" (ByVal hDC As Long)
  195. Private Declare Function apiExtFloodFill& Lib "gdi32" Alias "ExtFloodFill" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long)
  196. Private Declare Function apiFillPath& Lib "gdi32" Alias "FillPath" (ByVal hDC As Long)
  197. Private Declare Function apiFillRect& Lib "user32" Alias "FillRect" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long)
  198. Private Declare Function apiFlattenPath& Lib "gdi32" Alias "FlattenPath" (ByVal hDC As Long)
  199. Private Declare Function apiFloodFill& Lib "gdi32" Alias "FloodFill" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long)
  200. Private Declare Function apiFrameRect& Lib "user32" Alias "FrameRect" (ByVal hDC As Long, lpRect As RECT, ByVal hBrush As Long)
  201. Private Declare Function apiGdiComment& Lib "gdi32" Alias "GdiComment" (ByVal hDC As Long, ByVal cbSize As Long, lpData As Byte)
  202. Private Declare Function apiGetArcDirection& Lib "gdi32" Alias "GetArcDirection" (ByVal hDC As Long)
  203. Private Declare Function apiGetBkColor& Lib "gdi32" Alias "GetBkColor" (ByVal hDC As Long)
  204. Private Declare Function apiGetBkMode& Lib "gdi32" Alias "GetBkMode" (ByVal hDC As Long)
  205. Private Declare Function apiGetCurrentPositionEx& Lib "gdi32" Alias "GetCurrentPositionEx" (ByVal hDC As Long, lpPoint As POINTAPI)
  206. Private Declare Function apiGetMiterLimit& Lib "gdi32" Alias "GetMiterLimit" (ByVal hDC As Long, peLimit As Single)
  207. Private Declare Function apiGetNearestColor& Lib "gdi32" Alias "GetNearestColor" (ByVal hDC As Long, ByVal crColor As Long)
  208. Private Declare Function apiGetPath& Lib "gdi32" Alias "GetPath" (ByVal hDC As Long, lpPoint As POINTAPI, lpTypes As Byte, ByVal nSize As Long)
  209. Private Declare Function apiGetPixel& Lib "gdi32" Alias "GetPixel" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long)
  210. Private Declare Function apiGetPolyFillMode& Lib "gdi32" Alias "GetPolyFillMode" (ByVal hDC As Long)
  211. Private Declare Function apiGetROP2& Lib "gdi32" Alias "GetROP2" (ByVal hDC As Long)
  212. Private Declare Function apiInvertRect& Lib "user32" Alias "InvertRect" (ByVal hDC As Long, lpRect As RECT)
  213. Private Declare Function apiLineTo& Lib "gdi32" Alias "LineTo" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long)
  214. Private Declare Function apiMoveToEx& Lib "gdi32" Alias "MoveToEx" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI)
  215. Private Declare Function apiPathToRegion& Lib "gdi32" Alias "PathToRegion" (ByVal hDC As Long)
  216. Private Declare Function apiPie& Lib "gdi32" Alias "Pie" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long)
  217. Private Declare Function apiPlayEnhMetaFile& Lib "gdi32" Alias "PlayEnhMetaFile" (ByVal hDC As Long, ByVal hemf As Long, lpRect As RECT)
  218. Private Declare Function apiPlayEnhMetaFileRecord& Lib "gdi32" Alias "PlayEnhMetaFileRecord" (ByVal hDC As Long, lpHandleTable As HANDLETABLE, lpEnhMetaRecord As ENHMETARECORD, ByVal nHandles As Long)
  219. Private Declare Function apiPlayMetaFile& Lib "gdi32" Alias "PlayMetaFile" (ByVal hDC As Long, ByVal hMF As Long)
  220. Private Declare Function apiPolyBezier& Lib "gdi32" Alias "PolyBezier" (ByVal hDC As Long, lppt As POINTAPI, ByVal cPoints As Long)
  221. Private Declare Function apiPolyBezierTo& Lib "gdi32" Alias "PolyBezierTo" (ByVal hDC As Long, lppt As POINTAPI, ByVal cCount As Long)
  222. Private Declare Function apiPolyDraw& Lib "gdi32" Alias "PolyDraw" (ByVal hDC As Long, lppt As POINTAPI, lpbTypes As Byte, ByVal cCount As Long)
  223. Private Declare Function apiPolygon& Lib "gdi32" Alias "Polygon" (ByVal hDC As Long, lpPoint As POINTAPI, ByVal nCount As Long)
  224. Private Declare Function apiPolyline& Lib "gdi32" Alias "Polyline" (ByVal hDC As Long, lpPoint As POINTAPI, ByVal nCount As Long)
  225. Private Declare Function apiPolylineTo& Lib "gdi32" Alias "PolylineTo" (ByVal hDC As Long, lppt As POINTAPI, ByVal cCount As Long)
  226. Private Declare Function apiPolyPolyline& Lib "gdi32" Alias "PolyPolyline" (ByVal hDC As Long, lppt As POINTAPI, lpdwPolyPoints As Long, ByVal cCount As Long)
  227. Private Declare Function apiRectangle& Lib "gdi32" Alias "Rectangle" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long)
  228. Private Declare Function apiRoundRect& Lib "gdi32" Alias "RoundRect" (ByVal hDC As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, ByVal X3 As Long, ByVal Y3 As Long)
  229. Private Declare Function apiSetBkColor& Lib "gdi32" Alias "SetBkColor" (ByVal hDC As Long, ByVal crColor As Long)
  230. Private Declare Function apiSetArcDirection& Lib "gdi32" Alias "SetArcDirection" (ByVal hDC As Long, ByVal ArcDirection As Long)
  231. Private Declare Function apiSetBkMode& Lib "gdi32" Alias "SetBkMode" (ByVal hDC As Long, ByVal nBkMode As Long)
  232. Private Declare Function apiSetBrushOrgEx& Lib "gdi32" Alias "SetBrushOrgEx" (ByVal hDC As Long, ByVal nXOrg As Long, ByVal nYOrg As Long, lppt As POINTAPI)
  233. Private Declare Function apiSetMiterLimit& Lib "gdi32" Alias "SetMiterLimit" (ByVal hDC As Long, ByVal eNewLimit As Single, peOldLimit As Single)
  234. Private Declare Function apiSetPixel& Lib "gdi32" Alias "SetPixel" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long)
  235. Private Declare Function apiSetPixelV& Lib "gdi32" Alias "SetPixelV" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long)
  236. Private Declare Function apiSetPolyFillMode& Lib "gdi32" Alias "SetPolyFillMode" (ByVal hDC As Long, ByVal nPolyFillMode As Long)
  237. Private Declare Function apiSetROP2& Lib "gdi32" Alias "SetROP2" (ByVal hDC As Long, ByVal nDrawMode As Long)
  238. Private Declare Function apiStrokeAndFillPath& Lib "gdi32" Alias "StrokeAndFillPath" (ByVal hDC As Long)
  239. Private Declare Function apiStrokePath& Lib "gdi32" Alias "StrokePath" (ByVal hDC As Long)
  240. Private Declare Function apiWidenPath& Lib "gdi32" Alias "WidenPath" (ByVal hDC As Long)
  241. #Else
  242. 'Function AbortPath is not available in the WIN16 API.
  243. 'Function AngleArc is not available in the WIN16 API.
  244. Private Declare Function apiGetBrushOrgEx% Lib "gdi32" Alias "GetBrushOrgEx" (ByVal hDC As Integer, lpPoint As POINTAPI)
  245. Private Declare Function apiArc% Lib "gdi" Alias "Arc" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer, ByVal X4 As Integer, ByVal Y4 As Integer)
  246. Private Declare Function apiChord% Lib "gdi" Alias "Chord" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer, ByVal X4 As Integer, ByVal Y4 As Integer)
  247. Private Declare Function apiCloseMetaFile% Lib "gdi" Alias "CloseMetaFile" (ByVal hMF As Integer)
  248. Private Declare Function apiDeleteMetaFile% Lib "gdi" Alias "DeleteMetaFile" (ByVal hMF As Integer)
  249. Private Declare Function apiDeleteObject% Lib "gdi" Alias "DeleteObject" (ByVal hObject As Integer)
  250. Private Declare Sub apiDrawFocusRect Lib "user" Alias "DrawFocusRect" (ByVal hDC As Integer, lpRect As RECT)
  251. Private Declare Function apiEllipse% Lib "gdi" Alias "Ellipse" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer)
  252. Private Declare Function apiExtFloodFill% Lib "gdi" Alias "ExtFloodFill" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Long, ByVal wFillType As Integer)
  253. Private Declare Function apiFillRect% Lib "user" Alias "FillRect" (ByVal hDC As Integer, lpRect As RECT, ByVal hBrush As Integer)
  254. Private Declare Function apiFloodFill% Lib "gdi" Alias "FloodFill" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Long)
  255. Private Declare Function apiFrameRect% Lib "user" Alias "FrameRect" (ByVal hDC As Integer, lpRect As RECT, ByVal hBrush As Integer)
  256. Private Declare Function apiGetBkColor& Lib "gdi" Alias "GetBkColor" (ByVal hDC As Integer)
  257. Private Declare Function apiGetBkMode% Lib "gdi" Alias "GetBkMode" (ByVal hDC As Integer)
  258. Private Declare Function apiGetCurrentPositionEx% Lib "gdi" Alias "GetCurrentPositionEx" (ByVal hDC As Integer, lpPoint As POINTAPI)
  259. Private Declare Function apiGetNearestColor& Lib "gdi" Alias "GetNearestColor" (ByVal hDC As Integer, ByVal crColor As Long)
  260. Private Declare Function apiGetPixel& Lib "gdi" Alias "GetPixel" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer)
  261. Private Declare Function apiGetPolyFillMode% Lib "gdi" Alias "GetPolyFillMode" (ByVal hDC As Integer)
  262. Private Declare Function apiGetROP2% Lib "gdi" Alias "GetROP2" (ByVal hDC As Integer)
  263. Private Declare Sub apiInvertRect Lib "user" Alias "InvertRect" (ByVal hDC As Integer, lpRect As RECT)
  264. Private Declare Function apiLineTo% Lib "gdi" Alias "LineTo" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer)
  265. Private Declare Function apiMoveTo& Lib "gdi" Alias "MoveTo" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer)
  266. Private Declare Function apiMoveToEx% Lib "gdi" Alias "MoveToEx" (ByVal hDC As Integer, ByVal nX As Integer, ByVal nY As Integer, lpPoint As POINTAPI)
  267. Private Declare Function apiPie% Lib "gdi" Alias "Pie" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer, ByVal X4 As Integer, ByVal Y4 As Integer)
  268. Private Declare Function apiPlayMetaFile% Lib "gdi" Alias "PlayMetaFile" (ByVal hDC As Integer, ByVal hMF As Integer)
  269. Private Declare Function apiPolygon% Lib "gdi" Alias "Polygon" (ByVal hDC As Integer, lpPoints As POINTAPI, ByVal nCount As Integer)
  270. Private Declare Function apiPolyline% Lib "gdi" Alias "Polyline" (ByVal hDC As Integer, lpPoints As POINTAPI, ByVal nCount As Integer)
  271. Private Declare Function apiRectangle% Lib "gdi" Alias "Rectangle" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer)
  272. Private Declare Function apiRoundRect% Lib "gdi" Alias "RoundRect" (ByVal hDC As Integer, ByVal x1 As Integer, ByVal y1 As Integer, ByVal x2 As Integer, ByVal y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer)
  273. Private Declare Function apiSetBkColor& Lib "gdi" Alias "SetBkColor" (ByVal hDC As Integer, ByVal crColor As Long)
  274. Private Declare Function apiSetBkMode% Lib "gdi" Alias "SetBkMode" (ByVal hDC As Integer, ByVal nBkMode As Integer)
  275. Private Declare Function apiSetBrushOrg& Lib "gdi" Alias "SetBrushOrg" (ByVal hDC As Integer, ByVal nXOrg As Integer, ByVal nYOrg As Integer)
  276. Private Declare Function apiSetPixel& Lib "gdi" Alias "SetPixel" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Long)
  277. Private Declare Function apiSetPolyFillMode% Lib "gdi" Alias "SetPolyFillMode" (ByVal hDC As Integer, ByVal nPolyFillMode As Integer)
  278. Private Declare Function apiSetROP2% Lib "gdi" Alias "SetROP2" (ByVal hDC As Integer, ByVal nDrawMode As Integer)
  279. #End If 'WIN32
  280.  
  281.  
  282. #If Win32 Then
  283. Private Declare Function apiBitBlt& Lib "gdi32" Alias "BitBlt" (ByVal hDestDC 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 dwRop As Long)
  284. Private Declare Function apiMaskBlt& Lib "gdi32" Alias "MaskBlt" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long, ByVal dwRop As Long)
  285. Private Declare Function apiPlgBlt& Lib "gdi32" Alias "PlgBlt" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long)
  286. Private Declare Function apiPatBlt& Lib "gdi32" Alias "PatBlt" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long)
  287. Private Declare Function apiStretchBlt& Lib "gdi32" Alias "StretchBlt" (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)
  288. Private Declare Function apiReleaseDC& Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Long, ByVal hDC As Long)
  289. Private Declare Function apiGetDC& Lib "user32" Alias "GetDC" (ByVal hwnd As Long)
  290. Private Declare Function apiGetDCEx& Lib "user32" Alias "GetDCEx" (ByVal hwnd As Long, ByVal hrgnClip As Long, ByVal fdwOptions As Long)
  291. Private Declare Function apiSelectObject& Lib "gdi32" Alias "SelectObject" (ByVal hDC As Long, ByVal hObject As Long)
  292. Private Declare Function apiGetStockObject& Lib "gdi32" Alias "GetStockObject" (ByVal nIndex As Long)
  293. #Else
  294. Private Declare Function apiReleaseDC% Lib "user" Alias "ReleaseDC" (ByVal hwnd As Integer, ByVal hDC As Integer)
  295. Private Declare Function apiGetDC% Lib "user" Alias "GetDC" (ByVal hwnd As Integer)
  296. Private Declare Function apiGetDCEx% Lib "user" Alias "GetDCEx" (ByVal hwnd As Integer, ByVal hrgnClip As Integer, ByVal fdwOptions As Long)
  297. Private Declare Function apiSelectObject% Lib "gdi" Alias "SelectObject" (ByVal hDC As Integer, ByVal hObject As Integer)
  298. Private Declare Function apiGetStockObject% Lib "gdi" Alias "GetStockObject" (ByVal nIndex As Integer)
  299. Private Declare Function apiBitBlt% Lib "gdi" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer, ByVal YSrc As Integer, ByVal dwRop As Long)
  300. Private Declare Function apiPatBlt% Lib "gdi" Alias "PatBlt" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal dwRop As Long)
  301. Private Declare Function apiStretchBlt% Lib "gdi" Alias "StretchBlt" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer, ByVal YSrc As Integer, ByVal nSrcWidth As Integer, ByVal nSrcHeight As Integer, ByVal dwRop As Long)
  302. #End If 'WIN32
  303.  
  304.  
  305. Private Sub RaiseHdcError(Optional errval)
  306.     Dim useerr%
  307.     If IsMissing(errval) Then
  308.         RaiseHdcError DWERR_APIRESULT
  309.     Else
  310.         RaiseError errval, "dwDeviceContext"
  311.     End If
  312. End Sub
  313.  
  314. ' Clear out the current device context setting,
  315. ' deselecting any current objects
  316. Private Sub ClearDC()
  317.     
  318.     If iHDC = 0 Then Exit Sub ' Already clear
  319.     
  320.     ' Clear selected objects
  321. #If FlagBitmap = True Then
  322.     SelectObjectBitmap Nothing
  323. #End If
  324.     SelectObjectBrush Nothing
  325.     SelectObjectPen Nothing
  326.     
  327.     ' If we stored the initial state, restore now
  328.     If InitialSaveDC <> 0 Then
  329.         Call apiRestoreDC(iHDC, InitialSaveDC)
  330.         InitialSaveDC = 0
  331.     End If
  332.     Select Case DCsource
  333.         Case 0  ' GetDC
  334.                 Call apiReleaseDC(objwnd.hwnd, iHDC)
  335.         Case 1  ' CreateDC
  336.                 Call apiDeleteDC(iHDC)
  337.         Case 2  ' Assigment - Do nothing
  338.         Case 3  ' Metafile: Kill it
  339.                 Call apiDeleteMetaFile(apiCloseMetaFile(iHDC))
  340.         Case 4  ' Enhanced metafile - same as above
  341.                 #If Win32 Then
  342.                     Call apiDeleteEnhMetaFile(apiCloseEnhMetaFile(iHDC))
  343.                 #Else
  344.                     RaiseHdcError DWERR_NOTINWIN16
  345.                 #End If
  346.     End Select
  347.     iHDC = 0
  348.     DCsource = -1
  349.     Set objwnd = Nothing
  350.         
  351. End Sub
  352.  
  353. Public Property Get hDC() As Long
  354.     hDC = iHDC
  355. End Property
  356.  
  357. ' Intended for direct setting from the hDC property
  358. ' of a form, picture control, printer object or metafile.
  359. Public Property Let hDC(vNewValue As Long)
  360.     If DCsource <> 3 Then ' if not a metafile
  361.         If apiGetMapMode(vNewValue) = 0 Then RaiseHdcError 380
  362.         DCsource = 2    ' Direct setting
  363.         InitialSaveDC = apiSaveDC(iHDC)    ' Save initial state
  364.         ClearDC         ' Clear existing DC info
  365.     End If
  366.     iHDC = vNewValue
  367.     DeviceCaps.InitDevCaps iHDC
  368. End Property
  369.  
  370. Public Property Get IsMetafile() As Boolean
  371.     If DCsource = 3 Or DCsource = 4 Then IsMetafile = True
  372. End Property
  373.  
  374. Private Sub Class_Terminate()
  375.     ClearDC
  376. End Sub
  377.  
  378. ' Use GetDC on an existing window
  379. Public Sub GetDC(wnd As dwWindow)
  380. Attribute GetDC.VB_HelpID = 2922
  381. Attribute GetDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  382.     If wnd.hwnd = 0 Then RaiseHdcError 380
  383.     ClearDC
  384.     iHDC = apiGetDC(wnd.hwnd)
  385.     DCsource = 0
  386.     If iHDC = 0 Then RaiseHdcError DWERR_NODCAVAILABLE
  387.     InitialSaveDC = apiSaveDC(iHDC)
  388.     Set objwnd = wnd
  389.     DeviceCaps.InitDevCaps iHDC
  390. End Sub
  391.  
  392. Public Sub SelectObjectBrush(br As dwBrush)
  393.     Dim oldBrush&
  394.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  395.     
  396.     If br Is Nothing Then   ' Clear existing brush
  397.         ' No brush selected
  398.         If iCurrentBrush Is Nothing Then Exit Sub
  399.         Call apiSelectObject(iHDC, OriginalBrush)
  400.         Set iCurrentBrush = Nothing
  401.     Else
  402.         oldBrush = apiSelectObject(iHDC, br.hBrush)
  403.         If OriginalBrush = 0 Then OriginalBrush = oldBrush
  404.         Set iCurrentBrush = br
  405.     End If
  406. End Sub
  407.  
  408. #If FlagBitmap = True Then
  409. Public Sub SelectObjectBitmap(bm As dwBitmap)
  410.     Dim oldbitmap&
  411.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  412.     
  413.     If bm Is Nothing Then   ' Clear existing bitmap
  414.         ' No bitmap selected
  415.         If iCurrentBitmap Is Nothing Then Exit Sub
  416.         Call apiSelectObject(iHDC, OriginalBitmap)
  417.         Set iCurrentBitmap = Nothing
  418.     Else
  419.         oldbitmap = apiSelectObject(iHDC, bm.hBitmap)
  420.         If OriginalBitmap = 0 Then OriginalBitmap = oldbitmap
  421.         Set iCurrentBitmap = bm
  422.     End If
  423. End Sub
  424. #End If ' FlagBitmap
  425.  
  426. Public Sub SelectObjectPen(pn As dwPen)
  427.     Dim oldPen&
  428.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  429.     
  430.     If pn Is Nothing Then   ' Clear existing pen
  431.         ' No pen selected
  432.         If iCurrentPen Is Nothing Then Exit Sub
  433.         Call apiSelectObject(iHDC, OriginalPen)
  434.         Set iCurrentPen = Nothing
  435.     Else
  436.         oldPen = apiSelectObject(iHDC, pn.hPen)
  437.         If OriginalPen = 0 Then OriginalPen = oldPen
  438.         Set iCurrentPen = pn
  439.     End If
  440. End Sub
  441.  
  442. #If FlagMetaFile Then
  443. Public Function CloseMetafile() As dwMetaFile
  444. Attribute CloseMetafile.VB_HelpID = 2487
  445. Attribute CloseMetafile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  446.     Dim newMetafile As New dwMetaFile
  447.     
  448.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  449.     If DCsource <> 3 And DCsource <> 4 Then RaiseHdcError DWERR_NOTMETAFILEDC
  450.     
  451.     newMetafile.InitializeMetafile apiCloseMetaFile(iHDC), False
  452.     Set CloseMetafile = newMetafile
  453. End Function
  454. #End If ' FlagMetafile
  455.  
  456. #If FlagMetaFile Then
  457. Public Function CloseEnhMetaFile() As dwMetaFile
  458. Attribute CloseEnhMetaFile.VB_HelpID = 2639
  459. Attribute CloseEnhMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  460. #If Win32 Then
  461.     Dim newMetafile As New dwMetaFile
  462.     
  463.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  464.     If ((DCsource = 3) Or (DCsource = 4)) Then RaiseHdcError DWERR_NOTMETAFILEDC
  465.     
  466.     newMetafile.InitializeMetafile apiCloseEnhMetaFile(iHDC), True
  467.     Set CloseEnhMetaFile = newMetafile
  468. #Else
  469.     RaiseHdcError DWERR_NOTINWIN16
  470. #End If
  471. End Function
  472. #End If ' FlagMetafile
  473.  
  474. Public Function PathToRegion() As dwRegion
  475. Attribute PathToRegion.VB_HelpID = 2697
  476. Attribute PathToRegion.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  477. #If Win32 Then
  478.     Dim newRegion As New dwRegion
  479.     
  480.     newRegion.hRegion = apiPathToRegion(iHDC)
  481.     If GetLastError <> 0 Then RaiseHdcError
  482.     Set PathToRegion = newRegion
  483. #Else
  484.     RaiseHdcError DWERR_NOTINWIN16
  485. #End If
  486. End Function
  487.  
  488. Public Function CreateCompatibleDC() As dwDeviceContext
  489. Attribute CreateCompatibleDC.VB_HelpID = 2495
  490. Attribute CreateCompatibleDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  491.     Dim ret&
  492.     Dim tmpHDC As New dwDeviceContext
  493.     
  494.     If iHDC = 0 Then RaiseHdcError
  495.     
  496.     ret& = apiCreateCompatibleDC(iHDC)
  497.     If ret& = 0 Then RaiseHdcError
  498.     tmpHDC.hDC = ret&
  499.     Set CreateCompatibleDC = tmpHDC
  500. End Function
  501.          
  502. Public Sub CreateDC(lpDriverName As String, lpDeviceName As String, lpOutput As String, lpInitData As dwDevMode)
  503. Attribute CreateDC.VB_HelpID = 2496
  504. Attribute CreateDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  505. #If Win32 Then
  506.     Dim ret As Long
  507. #Else
  508.     Dim ret As Integer
  509. #End If
  510.     Dim tmpDevMode As DEVMODE
  511.     
  512.     lpOutput = ""
  513.     If lpInitData Is Nothing Then
  514.         ret = apiCreateDCByVal(lpDriverName, lpDeviceName, lpOutput, 0)
  515.     Else
  516.         #If Win32 Then
  517.             lpInitData.CopyToDEVMODE agGetAddressForObject(tmpDevMode.dmDeviceName)
  518.             ret = apiCreateDC(lpDriverName, lpDeviceName, lpOutput, tmpDevMode)
  519.         #Else
  520.             ret = apiCreateDC(lpDriverName, lpDeviceName, lpOutput, agGetAddressForObject(tmpDevMode.dmDeviceName))
  521.         #End If
  522.     End If
  523.     If ret = 0 Then RaiseHdcError
  524.     DCsource = 1
  525.     iHDC = ret
  526.     DeviceCaps.InitDevCaps iHDC
  527. End Sub
  528.  
  529. #If FlagUseArrayNotCollection Then
  530. Public Sub DPtoLP(lpPoints() As dwPoint, ByVal nCount)
  531. Attribute DPtoLP.VB_HelpID = 2696
  532. Attribute DPtoLP.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  533.     Dim tempPoints() As POINTAPI
  534.     Dim ret&
  535.     Dim i As Integer
  536.  
  537.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  538.     ReDim tempPoints(nCount - 1)
  539.     For i = 0 To nCount - 1
  540.         tempPoints(i).x = lpPoints(i).x
  541.         tempPoints(i).y = lpPoints(i).y
  542.     Next i
  543.     ret& = apiDPtoLP(iHDC, tempPoints(0), nCount)
  544.     If ret& = 0 Then RaiseHdcError
  545.     For i = 0 To nCount - 1
  546.         lpPoints(i).x = tempPoints(i).x
  547.         lpPoints(i).y = tempPoints(i).y
  548.     Next i
  549. End Sub
  550. #Else ' use Collection version
  551. ' colPoints should be a collection of dwPoints
  552. Public Sub DPtoLP(colPoints As Collection)
  553.     Dim tempPoints() As POINTAPI
  554.     Dim ret&
  555.     Dim i As Integer
  556.     
  557.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  558.     ReDim tempPoints(colPoints.count - 1)
  559.     For i = 1 To colPoints.count
  560.         tempPoints(i - 1).x = colPoints(i).x
  561.         tempPoints(i - 1).y = colPoints(i).y
  562.     Next i
  563.     ret& = apiDPtoLP(iHDC, tempPoints(0), colPoints.count)
  564.     If ret& = 0 Then RaiseHdcError
  565.     For i = 1 To colPoints.count
  566.         colPoints(i).x = tempPoints(i - 1).x
  567.         colPoints(i).y = tempPoints(i - 1).y
  568.     Next i
  569. End Sub
  570. #End If ' FlagUseArrayNotCollection
  571.  
  572. Public Function ExcludeClipRect(pRect As dwRECT) As Long
  573. Attribute ExcludeClipRect.VB_HelpID = 2528
  574. Attribute ExcludeClipRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  575.     Dim ret&
  576.     
  577.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  578.     ret& = apiExcludeClipRect(iHDC, pRect.left, pRect.top, pRect.right, pRect.bottom)
  579.     If ret& = ERRORAPI Then RaiseHdcError
  580.     ExcludeClipRect = ret&
  581. End Function
  582.  
  583. Public Function ExcludeUpdateRgn(hwnd As dwWindow) As Long
  584. Attribute ExcludeUpdateRgn.VB_HelpID = 2930
  585. Attribute ExcludeUpdateRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  586.     Dim ret&
  587.     
  588.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  589.     ret& = apiExcludeUpdateRgn(iHDC, hwnd.hwnd)
  590.     If ret& = ERRORAPI Then RaiseHdcError
  591.     ExcludeUpdateRgn = ret&
  592. End Function
  593.  
  594. Public Function ExtSelectClipRgn(hRgn As dwRegion, ByVal fnMode) As Long
  595. Attribute ExtSelectClipRgn.VB_HelpID = 2608
  596. Attribute ExtSelectClipRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  597. #If Win32 Then
  598.     Dim ret&
  599.     
  600.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  601.     ret& = apiExtSelectClipRgn(iHDC, hRgn.hRegion, fnMode)
  602.     If ret& = ERRORAPI Then RaiseHdcError
  603.     ExtSelectClipRgn = ret&
  604. #Else
  605.     RaiseHdcError DWERR_NOTINWIN16
  606. #End If
  607. End Function
  608.  
  609. Public Sub FillRegion(hRgn As dwRegion, hBrush As dwBrush)
  610.     Dim ret&
  611.     
  612.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  613.     ret& = apiFillRgn(iHDC, hRgn.hRegion, hBrush.hBrush)
  614.     If ret& = 0 Then RaiseHdcError
  615. End Sub
  616.  
  617. Public Sub FrameRgn(hRgn As dwRegion, hBrush As dwBrush, ByVal nWidth, ByVal nHeight)
  618. Attribute FrameRgn.VB_HelpID = 2532
  619. Attribute FrameRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  620.     Dim ret&
  621.     
  622.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  623.     ret& = apiFrameRgn(iHDC, hRgn.hRegion, hBrush.hBrush, nWidth, nHeight)
  624.     If ret& = 0 Then RaiseHdcError
  625. End Sub
  626.  
  627. ' ???:This returns unusually large numbers.
  628. Public Function GetBoundsRect(ByVal Flags) As dwRECT
  629. Attribute GetBoundsRect.VB_HelpID = 2540
  630. Attribute GetBoundsRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  631.     Dim tempRect As RECT
  632.     Dim newRect As New dwRECT
  633.     Dim ret&
  634.  
  635.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  636.     ret& = apiGetBoundsRect(iHDC, tempRect, Flags)
  637.     If ret& = 0 Then RaiseHdcError
  638.     newRect.SetRect tempRect.top, tempRect.left, tempRect.bottom, tempRect.right
  639.     Set GetBoundsRect = newRect
  640. End Function
  641.  
  642. Public Function GetClipBox() As dwRECT
  643. Attribute GetClipBox.VB_HelpID = 2546
  644. Attribute GetClipBox.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  645.     Dim tempRect As RECT
  646.     Dim newRect As New dwRECT
  647.     Dim ret&
  648.     
  649.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  650.     ret& = apiGetClipBox(iHDC, tempRect)
  651.     If ret& = 0 Then RaiseHdcError
  652.     newRect.SetRect tempRect.left, tempRect.top, tempRect.right, tempRect.bottom
  653.     Set GetClipBox = newRect
  654. End Function
  655.  
  656. Public Sub GetClipRgn(hRgn As dwRegion)
  657. Attribute GetClipRgn.VB_HelpID = 2547
  658. Attribute GetClipRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  659. #If Win32 Then
  660.     Dim ret&
  661.     
  662.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  663.     ret& = apiGetClipRgn(iHDC, hRgn.hRegion)
  664.     If ret& = 1 Then RaiseHdcError
  665. #Else
  666.     RaiseHdcError DWERR_NOTINWIN16
  667. #End If
  668. End Sub
  669.  
  670. Public Function GetDCOrgEx() As dwPoint
  671. Attribute GetDCOrgEx.VB_HelpID = 2715
  672. Attribute GetDCOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  673. #If Win32 Then
  674.     Dim tmpPoint As POINTAPI
  675.     Dim newPoint As New dwPoint
  676.     Dim ret&
  677.     
  678.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  679.     GetDCOrgEx = apiGetDCOrgEx(iHDC, tmpPoint)
  680.     If ret& = 0 Then RaiseHdcError
  681.     newPoint.x = tmpPoint.x
  682.     newPoint.y = tmpPoint.y
  683.     Set GetDCOrgEx = newPoint
  684. #Else
  685.     RaiseHdcError DWERR_NOTINWIN16
  686. #End If
  687. End Function
  688.  
  689. #If FlagGetDeviceCaps = True Then
  690. Public Function GetDeviceCaps() As dwDevCaps
  691. Attribute GetDeviceCaps.VB_HelpID = 2551
  692. Attribute GetDeviceCaps.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  693.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  694.     Set GetDeviceCaps = DeviceCaps
  695. End Function
  696. #End If 'FlagGetDeviceCaps
  697.  
  698. Public Function GetMapMode()
  699. Attribute GetMapMode.VB_HelpID = 2556
  700. Attribute GetMapMode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  701. #If Win32 Then
  702.     Dim ret&
  703.     
  704.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  705.     ret& = apiGetMapMode(iHDC)
  706.     If ret& = 0 Then RaiseHdcError
  707.     GetMapMode = ret&
  708. #Else
  709.     Dim ret%
  710.     
  711.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  712.     ret% = apiGetMapMode(iHDC)
  713.     If ret% = 0 Then RaiseHdcError
  714.     GetMapMode = ret%
  715. #End If
  716. End Function
  717.  
  718. Public Function GetRgnBox(hRgn As dwRegion) As dwRECT
  719. Attribute GetRgnBox.VB_HelpID = 2568
  720. Attribute GetRgnBox.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  721.     Dim newRect As New dwRECT
  722.     Dim tempRect As RECT
  723.     Dim ret&
  724.     
  725.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  726.     ret& = apiGetRgnBox(hRgn.hRegion, tempRect)
  727.     If ret& = 0 Then RaiseHdcError
  728.     newRect.SetRect tempRect.left, tempRect.top, tempRect.right, tempRect.bottom
  729.     Set GetRgnBox = newRect
  730. End Function
  731.  
  732. Public Function GetUpdateRegion(hwnd As dwWindow, ByVal fErase As Boolean) As dwRegion
  733. Attribute GetUpdateRegion.VB_HelpID = 2929
  734. Attribute GetUpdateRegion.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  735.     Dim newRegion As New dwRegion
  736.     Dim ret&
  737.     
  738.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  739.     ret& = apiGetUpdateRgn(iHDC, newRegion.hRegion, fErase)
  740.     If ret& = 0 Then RaiseHdcError
  741.     Set GetUpdateRegion = newRegion
  742. End Function
  743.  
  744. Public Function GetViewportExtEx() As dwPoint
  745. Attribute GetViewportExtEx.VB_HelpID = 2579
  746. Attribute GetViewportExtEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  747.     Dim newSize As New dwPoint
  748.     Dim tempSize As SIZE
  749.     Dim ret&
  750.     
  751.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  752.     ret& = apiGetViewportExtEx(iHDC, tempSize)
  753.     newSize.cx = tempSize.cx
  754.     newSize.cy = tempSize.cy
  755.     Set GetViewportExtEx = newSize
  756. End Function
  757.  
  758. Public Function GetViewportOrgEx() As dwPoint
  759. Attribute GetViewportOrgEx.VB_HelpID = 2580
  760. Attribute GetViewportOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  761.     Dim newPoint As New dwPoint
  762. #If Win32 Then
  763.     Dim tempPoint As POINTAPI
  764. #Else
  765.     Dim tempPoint As SIZE
  766. #End If
  767.     Dim ret&
  768.     
  769.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  770.     ret& = apiGetViewportOrgEx(iHDC, tempPoint)
  771.     If ret& = 0 Then RaiseHdcError
  772. #If Win32 Then
  773.     newPoint.x = tempPoint.x
  774.     newPoint.y = tempPoint.y
  775. #Else
  776.     newPoint.x = tempPoint.cx
  777.     newPoint.y = tempPoint.cy
  778. #End If
  779.     Set GetViewportOrgEx = newPoint
  780. End Function
  781.  
  782. Public Sub GetWindowDC(wnd As dwWindow)
  783. Attribute GetWindowDC.VB_HelpID = 2924
  784. Attribute GetWindowDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  785.     If wnd.hwnd = 0 Then RaiseHdcError 380
  786.     ClearDC
  787.     iHDC = apiGetWindowDC(wnd.hwnd)
  788.     DCsource = 0
  789.     If iHDC = 0 Then RaiseHdcError DWERR_NODCAVAILABLE
  790.     Set objwnd = wnd
  791.     DeviceCaps.InitDevCaps iHDC
  792. End Sub
  793.  
  794. Public Function GetWindowExtEx() As dwPoint
  795. Attribute GetWindowExtEx.VB_HelpID = 2581
  796. Attribute GetWindowExtEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  797.     Dim tempSize As SIZE
  798.     Dim tempExt As New dwPoint
  799.     Dim ret&
  800.     
  801.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  802.     ret& = apiGetWindowExtEx(iHDC, tempSize)
  803.     If ret& = 0 Then RaiseHdcError
  804.     tempExt.cx = tempSize.cx
  805.     tempExt.cy = tempSize.cy
  806.     Set GetWindowExtEx = tempExt
  807. End Function
  808.  
  809. Public Function GetWindowOrgEx() As dwPoint
  810. Attribute GetWindowOrgEx.VB_HelpID = 2582
  811. Attribute GetWindowOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  812. #If Win32 Then
  813.     Dim tempPoint As POINTAPI
  814. #Else
  815.     Dim tempPoint As SIZE
  816. #End If
  817.     Dim tempOrg As New dwPoint
  818.     Dim ret&
  819.     
  820.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  821.     ret& = apiGetWindowOrgEx(iHDC, tempPoint)
  822.     If ret& = 0 Then RaiseHdcError
  823. #If Win32 Then
  824.     tempOrg.x = tempPoint.x
  825.     tempOrg.y = tempPoint.y
  826. #Else
  827.     tempOrg.x = tempPoint.cx
  828.     tempOrg.y = tempPoint.cy
  829. #End If
  830.     Set GetWindowOrgEx = tempOrg
  831. End Function
  832.  
  833. Public Function IntersectClipRect(pRect As dwRECT) As Long
  834. Attribute IntersectClipRect.VB_HelpID = 2583
  835. Attribute IntersectClipRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  836.     Dim ret&
  837.     
  838.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  839.     ret& = apiIntersectClipRect(iHDC, pRect.left, pRect.top, pRect.right, pRect.bottom)
  840.     If ret& = ERRORAPI Then RaiseHdcError
  841.     IntersectClipRect = ret&
  842. End Function
  843.  
  844. Public Sub InvertRgn(hRgn As dwRegion)
  845. Attribute InvertRgn.VB_HelpID = 2584
  846. Attribute InvertRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  847.     Dim ret&
  848.     
  849.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  850.     ret& = apiInvertRgn(iHDC, hRgn.hRegion)
  851.     If ret& = 0 Then RaiseHdcError
  852. End Sub
  853.  
  854. #If FlagUseArrayNotCollection Then
  855. Public Sub LPtoDP(lpPoints() As dwPoint, ByVal nCount)
  856. Attribute LPtoDP.VB_HelpID = 2697
  857. Attribute LPtoDP.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  858.     Dim tempPoints() As POINTAPI
  859.     Dim ret&
  860.     Dim i As Integer
  861.     
  862.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  863.     ReDim tempPoints(nCount - 1)
  864.     For i = 0 To nCount - 1
  865.         tempPoints(i).x = lpPoints(i).x
  866.         tempPoints(i).y = lpPoints(i).y
  867.     Next i
  868.     ret& = apiLPtoDP(iHDC, tempPoints(0), nCount)
  869.     If ret& = 0 Then RaiseHdcError
  870.     For i = 0 To nCount - 1
  871.         lpPoints(i).x = tempPoints(i).x
  872.         lpPoints(i).y = tempPoints(i).y
  873.     Next i
  874. End Sub
  875. #Else ' use collection version
  876. ' colPoints should be a collection of dwPoints
  877. Public Sub LPtoDP(colPoints As Collection, ByVal nCount)
  878.     Dim tempPoints() As POINTAPI
  879.     Dim ret&
  880.     Dim i As Integer
  881.     
  882.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  883.     ReDim tempPoints(colPoints.count - 1)
  884.     For i = 1 To colPoints.count
  885.         tempPoints(i - 1).x = colPoints(i).x
  886.         tempPoints(i - 1).y = colPoints(i).y
  887.     Next i
  888.     ret& = apiLPtoDP(iHDC, tempPoints(0), colPoints.count)
  889.     If ret& = 0 Then RaiseHdcError
  890.     For i = 1 To colPoints.count
  891.         colPoints(i).x = tempPoints(i - 1).x
  892.         colPoints(i).y = tempPoints(i - 1).y
  893.     Next i
  894. End Sub
  895. #End If ' FlagUseArrayNotCollection
  896.  
  897. Public Function OffsetClipRgn(pPoint As dwPoint) As Long
  898. Attribute OffsetClipRgn.VB_HelpID = 2588
  899. Attribute OffsetClipRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  900.     Dim ret&
  901.      
  902.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  903.     ret& = apiOffsetClipRgn(iHDC, pPoint.x, pPoint.y)
  904.     If ret& = ERRORAPI Then RaiseHdcError
  905.     OffsetClipRgn = ret&
  906. End Function
  907.  
  908. Public Sub OffsetViewportOrgEx(ByVal nX, ByVal nY, lpPoint As dwPoint)
  909. Attribute OffsetViewportOrgEx.VB_HelpID = 2707
  910. Attribute OffsetViewportOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  911.     Dim tempPoint As POINTAPI
  912.     Dim ret&
  913.     
  914.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  915.     tempPoint.x = lpPoint.x
  916.     tempPoint.y = lpPoint.y
  917.     ret& = apiOffsetViewportOrgEx(iHDC, nX, nY, tempPoint)
  918.     If ret& = 0 Then RaiseHdcError
  919. End Sub
  920.  
  921. Public Sub PaintRgn(hRgn As dwRegion)
  922. Attribute PaintRgn.VB_HelpID = 2593
  923. Attribute PaintRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  924.     Dim ret&
  925.     
  926.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  927.     ret& = apiPaintRgn(iHDC, hRgn.hRegion)
  928.     If ret& = 0 Then RaiseHdcError
  929. End Sub
  930.  
  931. Public Function PtVisible(pPoint As dwPoint) As Long
  932. Attribute PtVisible.VB_HelpID = 2596
  933. Attribute PtVisible.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  934.     Dim ret&
  935.     
  936.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  937.     ret& = apiPtVisible(iHDC, pPoint.x, pPoint.y)
  938.     If ret& = 0 Then
  939.         PtVisible = False
  940.     Else
  941.         PtVisible = True
  942.     End If
  943. End Function
  944.  
  945. Public Sub RectVisible(rRect As dwRECT)
  946. Attribute RectVisible.VB_HelpID = 2597
  947. Attribute RectVisible.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  948.     Dim tempRect As RECT
  949.     Dim ret&
  950.     
  951.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  952.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  953.     ret& = apiRectVisible(iHDC, tempRect)
  954.     If ret& = 0 Then RaiseHdcError
  955. End Sub
  956.  
  957. Public Sub RestoreDC(ByVal nSavedDC)
  958. Attribute RestoreDC.VB_HelpID = 2600
  959. Attribute RestoreDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  960.     Dim ret&
  961.     
  962.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  963.     ret& = apiRestoreDC(iHDC, nSavedDC)
  964.     If ret& = 0 Then RaiseHdcError
  965. End Sub
  966.  
  967. Public Function SaveDC()
  968. Attribute SaveDC.VB_HelpID = 2606
  969. Attribute SaveDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  970. #If Win32 Then
  971.     Dim ret As Long
  972. #Else
  973.     Dim ret As Integer
  974. #End If
  975.         
  976.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  977.     ret = apiSaveDC(iHDC)
  978.     If ret = 0 Then RaiseHdcError
  979.     SaveDC = ret
  980. End Function
  981.  
  982. Public Sub ScaleViewportExtEx(ByVal nXnum, ByVal nXdenom, ByVal nYnum, ByVal nYdenom, lpSize As dwPoint)
  983. Attribute ScaleViewportExtEx.VB_HelpID = 2710
  984. Attribute ScaleViewportExtEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  985.     Dim tempSize As SIZE
  986.     Dim ret&
  987.     
  988.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  989.     tempSize.cx = lpSize.cx
  990.     tempSize.cy = lpSize.cy
  991.     ret& = apiScaleViewportExtEx(iHDC, nXnum, nXdenom, nYnum, nYdenom, tempSize)
  992.     If ret& = 0 Then RaiseHdcError
  993. End Sub
  994.  
  995. Public Sub ScaleWindowExtEx(ByVal nXnum, ByVal nXdenom, ByVal nYnum, ByVal nYdenom, lpSize As dwPoint)
  996. Attribute ScaleWindowExtEx.VB_HelpID = 2709
  997. Attribute ScaleWindowExtEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  998.     Dim tempSize As SIZE
  999.     Dim ret&
  1000.     
  1001.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1002.     tempSize.cx = lpSize.cx
  1003.     tempSize.cy = lpSize.cy
  1004.     ret& = apiScaleWindowExtEx(iHDC, nXnum, nXdenom, nYnum, nYdenom, tempSize)
  1005.     If ret& = 0 Then RaiseHdcError
  1006. End Sub
  1007.  
  1008. Public Sub ScrollDC(ByVal dx, ByVal dy, lprcScroll As dwRECT, lprcClip As dwRECT, ByVal hRgnUpdate, lprcUpdate As dwRECT)
  1009. Attribute ScrollDC.VB_HelpID = 2940
  1010. Attribute ScrollDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1011.     Dim tempRect1 As RECT
  1012.     Dim tempRect2 As RECT
  1013.     Dim tempRect3 As RECT
  1014.     Dim ret&
  1015.     
  1016.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1017.     lprcScroll.CopyToRECT agGetAddressForObject(tempRect1.left)
  1018.     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  1019.     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect3.left)
  1020.     ret& = apiScrollDC(iHDC, dx, dy, tempRect1, tempRect2, hRgnUpdate.hRegion, tempRect3)
  1021.     If ret& = 0 Then RaiseHdcError
  1022. End Sub
  1023.  
  1024. Public Sub SelectClipRgn(hRgn As dwRegion)
  1025. Attribute SelectClipRgn.VB_HelpID = 2607
  1026. Attribute SelectClipRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1027.     Dim ret&
  1028.     
  1029.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1030.     ret& = apiSelectClipRgn(iHDC, hRgn.hRegion)
  1031.     If ret& = 0 Then RaiseHdcError
  1032. End Sub
  1033.  
  1034. Public Function SetBoundsRect(lprcBounds As dwRECT, ByVal Flags) As Long
  1035. Attribute SetBoundsRect.VB_HelpID = 2615
  1036. Attribute SetBoundsRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1037.     Dim tempRect As RECT
  1038.     Dim ret&
  1039.     
  1040.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1041.     lprcBounds.CopyToRECT agGetAddressForObject(tempRect.left)
  1042.     ret& = apiSetBoundsRect(iHDC, tempRect, Flags)
  1043.     If ret& = 0 Then RaiseHdcError
  1044.     SetBoundsRect = ret&
  1045. End Function
  1046.  
  1047. Public Function SetMapMode(ByVal nMapMode) As Long
  1048. Attribute SetMapMode.VB_HelpID = 2620
  1049. Attribute SetMapMode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1050.     Dim ret&
  1051.     
  1052.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1053.     ret& = apiSetMapMode(iHDC, nMapMode)
  1054.     If ret& = 0 Then RaiseHdcError
  1055.     SetMapMode = ret&
  1056. End Function
  1057.  
  1058. Public Sub SetViewportExtEx(ByVal nX, ByVal nY, lpSize As dwPoint)
  1059. Attribute SetViewportExtEx.VB_HelpID = 2703
  1060. Attribute SetViewportExtEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1061.     Dim tempSize As SIZE
  1062.     Dim ret&
  1063.     
  1064.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1065.     tempSize.cx = lpSize.cx
  1066.     tempSize.cy = lpSize.cy
  1067.     ret& = apiSetViewportExtEx(iHDC, nX, nY, tempSize)
  1068.     If ret& = 0 Then RaiseHdcError
  1069. End Sub
  1070.  
  1071. Public Sub SetViewportOrgEx(ByVal nX, ByVal nY, lpPoint As dwPoint)
  1072. Attribute SetViewportOrgEx.VB_HelpID = 2704
  1073. Attribute SetViewportOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1074. #If Win32 Then
  1075.     Dim tempPoint As POINTAPI
  1076. #Else
  1077.     Dim tempPoint As SIZE
  1078. #End If
  1079.     Dim ret&
  1080.     
  1081.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1082. #If Win32 Then
  1083.     tempPoint.x = lpPoint.x
  1084.     tempPoint.y = lpPoint.y
  1085. #Else
  1086.     tempPoint.cx = lpPoint.x
  1087.     tempPoint.cy = lpPoint.y
  1088. #End If
  1089.     ret& = apiSetViewportOrgEx(iHDC, nX, nY, tempPoint)
  1090.     If ret& = 0 Then RaiseHdcError
  1091. End Sub
  1092.  
  1093. Public Sub SetWindowExtEx(ByVal nX, ByVal nY, lpSize As dwPoint)
  1094. Attribute SetWindowExtEx.VB_HelpID = 2706
  1095. Attribute SetWindowExtEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1096.     Dim tempSize As SIZE
  1097.     Dim ret&
  1098.     
  1099.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1100.     ret& = apiSetWindowExtEx(iHDC, nX, nY, tempSize)
  1101.     lpSize.cx = tempSize.cx
  1102.     lpSize.cy = tempSize.cy
  1103.     If ret& = 0 Then RaiseHdcError
  1104. End Sub
  1105.  
  1106. Public Sub SetWindowOrgEx(ByVal nX, ByVal nY, lpPoint As dwPoint)
  1107. Attribute SetWindowOrgEx.VB_HelpID = 2705
  1108. Attribute SetWindowOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1109. #If Win32 Then
  1110.     Dim tempPoint As POINTAPI
  1111. #Else
  1112.     Dim tempPoint As SIZE
  1113. #End If
  1114.     Dim ret&
  1115.     
  1116.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1117. #If Win32 Then
  1118.     tempPoint.x = lpPoint.x
  1119.     tempPoint.y = lpPoint.y
  1120. #Else
  1121.     tempPoint.cx = lpPoint.x
  1122.     tempPoint.cy = lpPoint.y
  1123. #End If
  1124.     ret& = apiSetWindowOrgEx(iHDC, nX, nY, tempPoint)
  1125.     If ret& = 0 Then RaiseHdcError
  1126. End Sub
  1127.  
  1128. Public Function WindowFromDC() As Long
  1129. Attribute WindowFromDC.VB_HelpID = 2921
  1130. Attribute WindowFromDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1131. #If Win32 Then
  1132.     Dim ret&
  1133.     
  1134.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1135.     ret& = apiWindowFromDC(iHDC)
  1136.     If ret& = 0 Then RaiseHdcError
  1137. #Else
  1138.     RaiseHdcError DWERR_NOTINWIN16
  1139. #End If
  1140. End Function
  1141.  
  1142. Public Sub DrawEdge(qrc As dwRECT, ByVal edge, ByVal grfFlags)
  1143. Attribute DrawEdge.VB_HelpID = 3539
  1144. #If Win32 Then
  1145.     Dim tempRect As RECT
  1146.     Dim ret&
  1147.     
  1148.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1149.     qrc.CopyToRECT agGetAddressForObject(tempRect.left)
  1150.     ret& = apiDrawEdge(iHDC, tempRect, edge, grfFlags)
  1151.     If ret& = 0 Then RaiseHdcError
  1152. #Else
  1153.     RaiseHdcError DWERR_NOTINWIN16
  1154. #End If
  1155. End Sub
  1156.  
  1157. Public Function GetBrushOrgEx() As dwPoint
  1158. Attribute GetBrushOrgEx.VB_HelpID = 2503
  1159. Attribute GetBrushOrgEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1160.     Dim tempPoint As POINTAPI
  1161.     Dim tempOrg As New dwPoint
  1162.     Dim ret&
  1163.     
  1164.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1165.     ret& = apiGetBrushOrgEx(iHDC, tempPoint)
  1166.     If ret& = 0 Then RaiseHdcError
  1167.     tempOrg.x = tempPoint.x
  1168.     tempOrg.y = tempPoint.y
  1169.     Set GetBrushOrgEx = tempOrg
  1170. End Function
  1171.  
  1172. Public Sub PaintDesktop()
  1173. Attribute PaintDesktop.VB_HelpID = 3571
  1174. Attribute PaintDesktop.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1175. #If Win32 Then
  1176.     Dim ret&
  1177.     
  1178.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1179.     ret& = apiPaintDesktop(iHDC)
  1180.     If ret& = 0 Then RaiseHdcError
  1181. #Else
  1182.     RaiseHdcError DWERR_NOTINWIN16
  1183. #End If
  1184. End Sub
  1185.  
  1186. Public Sub SelectClipPath(iMode As Long)
  1187. Attribute SelectClipPath.VB_HelpID = 2681
  1188. Attribute SelectClipPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1189. #If Win32 Then
  1190.     Dim ret&
  1191.     
  1192.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1193.     ret& = apiSelectClipPath(iHDC, iMode)
  1194.     If ret& = 0 Then RaiseHdcError
  1195. #Else
  1196.     RaiseHdcError DWERR_NOTINWIN16
  1197. #End If
  1198. End Sub
  1199.  
  1200. Public Sub AbortPath()
  1201. #If Win32 Then
  1202.     Dim ret&
  1203.     
  1204.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1205.     ret& = apiAbortPath(iHDC)
  1206.     If ret& = 0 Then RaiseHdcError
  1207. #Else
  1208.     RaiseHdcError DWERR_NOTINWIN16
  1209. #End If
  1210. End Sub
  1211.  
  1212. Public Sub AngleArc(pPoint As dwPoint, dwRadius As Long, eStartAngle As Double, eSweepAngle As Double)
  1213. Attribute AngleArc.VB_HelpID = 2657
  1214. Attribute AngleArc.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1215. #If Win32 Then
  1216.     Dim ret&
  1217.     
  1218.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1219.     ret& = apiAngleArc(iHDC, pPoint.x, pPoint.y, dwRadius, eStartAngle, eSweepAngle)
  1220.     If ret& = 0 Then RaiseHdcError
  1221. #Else
  1222.     RaiseHdcError DWERR_NOTINWIN16
  1223. #End If
  1224. End Sub
  1225.  
  1226. Public Sub ArcTo(pPoint1 As dwPoint, pPoint2 As dwPoint, pPoint3 As dwPoint, pPoint4 As dwPoint)
  1227. Attribute ArcTo.VB_HelpID = 2672
  1228. Attribute ArcTo.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1229. #If Win32 Then
  1230.     Dim ret&
  1231.     
  1232.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1233.     ret& = apiArcTo(iHDC, pPoint1.x, pPoint1.y, pPoint2.x, pPoint2.y, pPoint3.x, pPoint3.y, pPoint4.x, pPoint4.y)
  1234.     If ret& = 0 Then RaiseHdcError
  1235. #Else
  1236.     RaiseHdcError DWERR_NOTINWIN16
  1237. #End If
  1238. End Sub
  1239.  
  1240. Public Sub Arc(pPoint1 As dwPoint, pPoint2 As dwPoint, pPoint3 As dwPoint, pPoint4 As dwPoint)
  1241. Attribute Arc.VB_HelpID = 2483
  1242. Attribute Arc.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1243.     Dim ret&
  1244.     
  1245.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1246.     ret& = apiArc(iHDC, pPoint1.x, pPoint1.y, pPoint2.x, pPoint2.y, pPoint3.x, pPoint3.y, pPoint4.x, pPoint4.y)
  1247.     If ret& = 0 Then RaiseHdcError
  1248. End Sub
  1249.  
  1250. Public Sub BeginPath()
  1251. Attribute BeginPath.VB_HelpID = 2673
  1252. Attribute BeginPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1253. #If Win32 Then
  1254.     Dim ret&
  1255.     
  1256.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1257.     ret& = apiBeginPath(iHDC)
  1258.     If ret& = 0 Then RaiseHdcError
  1259. #Else
  1260.     RaiseHdcError DWERR_NOTINWIN16
  1261. #End If
  1262. End Sub
  1263.  
  1264. Public Sub CancelDC()
  1265. Attribute CancelDC.VB_HelpID = 2485
  1266. Attribute CancelDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1267. #If Win32 Then
  1268.     Dim ret&
  1269.     
  1270.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1271.     ret& = apiCancelDC(iHDC)
  1272.     If ret& = 0 Then RaiseHdcError
  1273. #Else
  1274.     RaiseHdcError DWERR_NOTINWIN16
  1275. #End If
  1276. End Sub
  1277.  
  1278. Public Sub Chord(pPoint1 As dwPoint, pPoint2 As dwPoint, pPoint3 As dwPoint, pPoint4 As dwPoint)
  1279. Attribute Chord.VB_HelpID = 2486
  1280. Attribute Chord.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1281.     Dim ret&
  1282.     
  1283.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1284.     ret& = apiChord(iHDC, pPoint1.x, pPoint1.y, pPoint2.x, pPoint2.y, pPoint3.x, pPoint3.y, pPoint4.x, pPoint4.y)
  1285.     If ret& = 0 Then RaiseHdcError
  1286. End Sub
  1287.  
  1288. Public Sub CloseFigure()
  1289. Attribute CloseFigure.VB_HelpID = 2674
  1290. Attribute CloseFigure.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1291. #If Win32 Then
  1292.     Dim ret&
  1293.     
  1294.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1295.     ret& = apiCloseFigure(iHDC)
  1296.     If ret& = 0 Then RaiseHdcError
  1297. #Else
  1298.     RaiseHdcError DWERR_NOTINWIN16
  1299. #End If
  1300. End Sub
  1301.  
  1302. Public Sub CopyEnhMetaFile(hemfSrc As Long, lpszFile As String)
  1303. Attribute CopyEnhMetaFile.VB_HelpID = 2640
  1304. Attribute CopyEnhMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1305. #If Win32 Then
  1306.     Dim ret&
  1307.     
  1308.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1309.     ret& = apiCopyEnhMetaFile(hemfSrc, lpszFile)
  1310.     If ret& = 0 Then RaiseHdcError
  1311. #Else
  1312.     RaiseHdcError DWERR_NOTINWIN16
  1313. #End If
  1314. End Sub
  1315.  
  1316. Public Sub CreateEnhMetaFile(hdcRef As Long, lpFileName As String, rRect As dwRECT, lpDescription As String)
  1317. Attribute CreateEnhMetaFile.VB_HelpID = 2641
  1318. Attribute CreateEnhMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1319. #If Win32 Then
  1320.     Dim tempRect As RECT
  1321.     Dim ret&
  1322.     
  1323.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1324.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  1325.     ret& = apiCreateEnhMetaFile(hdcRef, lpFileName, tempRect, lpDescription)
  1326.     If ret& = 0 Then RaiseHdcError
  1327.     iHDC = ret&
  1328.     DCsource = 4
  1329.     DeviceCaps.InitDevCaps iHDC
  1330. #Else
  1331.     RaiseHdcError DWERR_NOTINWIN16
  1332. #End If
  1333. End Sub
  1334.  
  1335. Public Sub DrawEscape(nEscape As Long, cbInput As Long, lpszInData As String)
  1336. Attribute DrawEscape.VB_HelpID = 2527
  1337. #If Win32 Then
  1338.     Dim ret&
  1339.     
  1340.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1341.     ret& = apiDrawEscape(iHDC, nEscape, cbInput, lpszInData)
  1342.     If ret& = 0 Then RaiseHdcError
  1343. #Else
  1344.     RaiseHdcError DWERR_NOTINWIN16
  1345. #End If
  1346. End Sub
  1347.  
  1348. Public Sub DrawFocusRect(rRect As dwRECT)
  1349. Attribute DrawFocusRect.VB_HelpID = 2984
  1350.     Dim tempRect As RECT
  1351.     Dim ret&
  1352.     
  1353.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1354.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  1355. #If Win32 Then
  1356.     ret& = apiDrawFocusRect(iHDC, tempRect)
  1357.     If ret& = 0 Then RaiseHdcError
  1358. #Else
  1359.     apiDrawFocusRect iHDC, tempRect
  1360. #End If
  1361. End Sub
  1362.  
  1363. Public Sub Ellipse(pRect As dwRECT)
  1364. Attribute Ellipse.VB_HelpID = 2523
  1365. Attribute Ellipse.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1366.     Dim ret&
  1367.     
  1368.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1369.     ret& = apiEllipse(iHDC, pRect.left, pRect.top, pRect.right, pRect.bottom)
  1370.     If ret& = 0 Then RaiseHdcError
  1371. End Sub
  1372.  
  1373. Public Sub EndPath()
  1374. Attribute EndPath.VB_HelpID = 2675
  1375. Attribute EndPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1376. #If Win32 Then
  1377.     Dim ret&
  1378.     
  1379.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1380.     ret& = apiEndPath(iHDC)
  1381.     If ret& = 0 Then RaiseHdcError
  1382. #Else
  1383.     RaiseHdcError DWERR_NOTINWIN16
  1384. #End If
  1385. End Sub
  1386.  
  1387. Public Sub ExtFloodFill(pPoint As dwPoint, ByVal crColor, ByVal wFillType)
  1388. Attribute ExtFloodFill.VB_HelpID = 2530
  1389. Attribute ExtFloodFill.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1390.     Dim ret&
  1391.     
  1392.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1393.     ret& = apiExtFloodFill(iHDC, pPoint.x, pPoint.y, crColor, wFillType)
  1394.     If ret& = 0 Then RaiseHdcError
  1395. End Sub
  1396.  
  1397. Public Sub FillPath()
  1398. Attribute FillPath.VB_HelpID = 2676
  1399. Attribute FillPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1400. #If Win32 Then
  1401.     Dim ret&
  1402.     
  1403.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1404.     ret& = apiFillPath(iHDC)
  1405.     If ret& = 0 Then RaiseHdcError
  1406. #Else
  1407.     RaiseHdcError DWERR_NOTINWIN16
  1408. #End If
  1409. End Sub
  1410.  
  1411. Public Sub FillRect(rRect As dwRECT, hBrush As dwBrush)
  1412. Attribute FillRect.VB_HelpID = 2985
  1413. Attribute FillRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1414.     Dim tempRect As RECT
  1415.     Dim ret&
  1416.     
  1417.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1418.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  1419.     ret& = apiFillRect(iHDC, tempRect, hBrush.hBrush)
  1420.     If ret& = 0 Then RaiseHdcError
  1421. End Sub
  1422.  
  1423. Public Sub FlattenPath()
  1424. Attribute FlattenPath.VB_HelpID = 2677
  1425. Attribute FlattenPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1426. #If Win32 Then
  1427.     Dim ret&
  1428.     
  1429.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1430.     ret& = apiFlattenPath(iHDC)
  1431.     If ret& = 0 Then RaiseHdcError
  1432. #Else
  1433.     RaiseHdcError DWERR_NOTINWIN16
  1434. #End If
  1435. End Sub
  1436.  
  1437. Public Sub FloodFill(pPoint As dwPoint, crColor As Long)
  1438. Attribute FloodFill.VB_HelpID = 2533
  1439. Attribute FloodFill.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1440.     Dim ret&
  1441.     
  1442.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1443.     ret& = apiFloodFill(iHDC, pPoint.x, pPoint.y, crColor)
  1444.     If ret& = 0 Then RaiseHdcError
  1445. End Sub
  1446.  
  1447. Public Sub FrameRect(rRect As dwRECT, hBrush As dwBrush)
  1448. Attribute FrameRect.VB_HelpID = 2986
  1449. Attribute FrameRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1450.     Dim tempRect As RECT
  1451.     Dim ret&
  1452.     
  1453.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1454.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  1455.     ret& = apiFrameRect(iHDC, tempRect, hBrush.hBrush)
  1456.     If ret& = 0 Then RaiseHdcError
  1457. End Sub
  1458.  
  1459. Public Sub GdiComment(cbSize As Long, lpData As Byte)
  1460. Attribute GdiComment.VB_HelpID = 2655
  1461. Attribute GdiComment.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1462. #If Win32 Then
  1463.     Dim ret&
  1464.     
  1465.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1466.     ret& = apiGdiComment(iHDC, cbSize, lpData)
  1467.     If ret& = 0 Then RaiseHdcError
  1468. #Else
  1469.     RaiseHdcError DWERR_NOTINWIN16
  1470. #End If
  1471. End Sub
  1472.  
  1473. Public Function GetArcDirection() As Long
  1474. Attribute GetArcDirection.VB_HelpID = 2689
  1475. Attribute GetArcDirection.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1476. #If Win32 Then
  1477.     Dim ret&
  1478.     
  1479.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1480.     ret& = apiGetArcDirection(iHDC)
  1481.     If ret& = 0 Then RaiseHdcError
  1482.     GetArcDirection = ret&
  1483. #Else
  1484.     RaiseHdcError DWERR_NOTINWIN16
  1485. #End If
  1486. End Function
  1487.  
  1488. Public Function GetBkColor() As Long
  1489. Attribute GetBkColor.VB_HelpID = 2536
  1490. Attribute GetBkColor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1491.     Dim ret&
  1492.     
  1493.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1494.     ret& = apiGetBkColor(iHDC)
  1495.     If ret& = 0 Then RaiseHdcError
  1496.     GetBkColor = ret&
  1497. End Function
  1498.  
  1499. Public Function GetBkMode() As Long
  1500. Attribute GetBkMode.VB_HelpID = 2537
  1501. Attribute GetBkMode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1502.     Dim ret&
  1503.     
  1504.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1505.     ret& = apiGetBkMode(iHDC)
  1506.     If ret& = 0 Then RaiseHdcError
  1507.     GetBkMode = ret&
  1508. End Function
  1509.  
  1510. Public Function GetCurrentPositionEx() As dwPoint
  1511. Attribute GetCurrentPositionEx.VB_HelpID = 2550
  1512. Attribute GetCurrentPositionEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1513.     Dim tempPosition As New dwPoint
  1514.     Dim tempPoint As POINTAPI
  1515.     Dim ret&
  1516.     
  1517.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1518.     ret& = apiGetCurrentPositionEx(iHDC, tempPoint)
  1519.     tempPosition.x = tempPoint.x
  1520.     tempPosition.y = tempPoint.y
  1521.     If ret& = 0 Then RaiseHdcError
  1522.     Set GetCurrentPositionEx = tempPosition
  1523. End Function
  1524.  
  1525. Public Function GetMiterLimit() As Single
  1526. Attribute GetMiterLimit.VB_HelpID = 2688
  1527. Attribute GetMiterLimit.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1528. #If Win32 Then
  1529.     Dim ret&
  1530.     Dim limit As Single
  1531.     
  1532.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1533.     ret& = apiGetMiterLimit(iHDC, limit)
  1534.     If ret& = 0 Then RaiseHdcError
  1535.     GetMiterLimit = limit
  1536. #Else
  1537.     RaiseHdcError DWERR_NOTINWIN16
  1538. #End If
  1539. End Function
  1540.  
  1541. Public Function GetNearestColor(crColor As Long) As Long
  1542. Attribute GetNearestColor.VB_HelpID = 2559
  1543. Attribute GetNearestColor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1544.     Dim ret&
  1545.     
  1546.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1547.     ret& = apiGetNearestColor(iHDC, crColor)
  1548.     If ret& = 0 Then RaiseHdcError
  1549.     GetNearestColor = ret&
  1550. End Function
  1551.  
  1552. #If FlagUseArrayNotCollection Then
  1553. Public Function GetPath(lpPoints() As dwPoint, lpTypes() As Byte) As Long
  1554. Attribute GetPath.VB_HelpID = 2678
  1555. Attribute GetPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1556. #If Win32 Then
  1557.     Dim tempPoints() As POINTAPI
  1558.     Dim ret&
  1559.     Dim i As Integer
  1560.     
  1561.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1562.     ReDim tempPoints(1)
  1563.     ReDim lpTypes(1)
  1564.     ret& = apiGetPath(iHDC, tempPoints(0), lpTypes(0), 0)
  1565.     If ret& = -1 Then RaiseHdcError
  1566.     ReDim tempPoints(ret&)
  1567.     ReDim lpTypes(ret&)
  1568.     ReDim lpPoints(ret&)
  1569.     ret& = apiGetPath(iHDC, tempPoints(0), lpTypes(0), ret&)
  1570.     If ret& = -1 Then RaiseHdcError
  1571.     For i = 0 To ret& - 1
  1572.         Set lpPoints(i) = New dwPoint
  1573.         lpPoints(i).x = tempPoints(i).x
  1574.         lpPoints(i).y = tempPoints(i).y
  1575.     Next i
  1576.     GetPath = ret&
  1577. #Else
  1578.     RaiseSysError DWERR_NOTINWIN16
  1579. #End If
  1580. End Function
  1581. #Else ' use collection version
  1582. ' colPoints will be a collection of dwPoints, colTypes of Bytes
  1583. Public Function GetPath(colPoints As Collection, colTypes As Collection) As Long
  1584. #If Win32 Then
  1585.     Dim tempPoints() As POINTAPI
  1586.     Dim tempBytes() As Byte
  1587.     Dim tempCPoints As New Collection
  1588.     Dim tempCTypes As New Collection
  1589.     Dim pPoint As dwPoint
  1590.     Dim ret&
  1591.     Dim i As Integer
  1592.     
  1593.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1594.     ReDim tempPoints(1)
  1595.     ReDim tempBytes(1)
  1596.     ret& = apiGetPath(iHDC, tempPoints(0), tempBytes(0), 0)
  1597.     If ret& = -1 Then RaiseHdcError
  1598.     ReDim tempPoints(ret&)
  1599.     ReDim tempBytes(ret&)
  1600.  
  1601.     ret& = apiGetPath(iHDC, tempPoints(0), tempBytes(0), ret&)
  1602.     If ret& = -1 Then RaiseHdcError
  1603.     For i = 0 To ret& - 1
  1604.         Set pPoint = New dwPoint
  1605.         pPoint.x = tempPoints(i).x
  1606.         pPoint.y = tempPoints(i).y
  1607.         tempCPoints.Add Item:=pPoint
  1608.         tempCTypes.Add Item:=tempBytes(i)
  1609.         Set pPoint = Nothing
  1610.     Next i
  1611.     Set colPoints = tempCPoints
  1612.     Set colTypes = tempCTypes
  1613.     
  1614.     Set tempCPoints = Nothing
  1615.     Set tempCTypes = Nothing
  1616.     GetPath = ret&
  1617. #Else
  1618.     RaiseHdcError DWERR_NOTINWIN16
  1619. #End If
  1620. End Function
  1621. #End If ' FlagUseArrayNotCollection
  1622.  
  1623. Public Function GetPixel(pPoint As dwPoint) As Long
  1624. Attribute GetPixel.VB_HelpID = 2564
  1625. Attribute GetPixel.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1626.     Dim ret&
  1627.     
  1628.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1629.     ret& = apiGetPixel(iHDC, pPoint.x, pPoint.y)
  1630.     If ret& = -1 Then RaiseHdcError
  1631.     GetPixel = ret&
  1632. End Function
  1633.  
  1634. Public Function GetPolyFillMode() As Long
  1635. Attribute GetPolyFillMode.VB_HelpID = 2565
  1636. Attribute GetPolyFillMode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1637.     Dim ret&
  1638.     
  1639.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1640.     ret& = apiGetPolyFillMode(iHDC)
  1641.     If ret& = 0 Then RaiseHdcError
  1642.     GetPolyFillMode = ret&
  1643. End Function
  1644.  
  1645. Public Function GetROP2() As Long
  1646. Attribute GetROP2.VB_HelpID = 2534
  1647. Attribute GetROP2.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1648.     Dim ret&
  1649.     
  1650.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1651.     ret& = apiGetROP2(iHDC)
  1652.     If ret& = 0 Then RaiseHdcError
  1653.     GetROP2 = ret&
  1654. End Function
  1655.  
  1656. Public Sub InvertRect(rRect As dwRECT)
  1657. Attribute InvertRect.VB_HelpID = 2987
  1658. Attribute InvertRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1659.     Dim tempRect As RECT
  1660.     Dim ret&
  1661.     
  1662.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1663.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  1664. #If Win32 Then
  1665.     ret& = apiInvertRect(iHDC, tempRect)
  1666.     If ret& = 0 Then RaiseHdcError
  1667. #Else
  1668.     apiInvertRect iHDC, tempRect
  1669. #End If
  1670.     rRect.SetRect tempRect.left, tempRect.top, tempRect.right, tempRect.bottom
  1671. End Sub
  1672.  
  1673. Public Sub LineTo(pPoint As dwPoint)
  1674. Attribute LineTo.VB_HelpID = 2585
  1675. Attribute LineTo.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1676.     Dim ret&
  1677.     
  1678.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1679.     ret& = apiLineTo(iHDC, pPoint.x, pPoint.y)
  1680.     If ret& = 0 Then RaiseHdcError
  1681. End Sub
  1682.  
  1683. Public Sub MoveTo(pPoint As dwPoint)
  1684. Attribute MoveTo.VB_HelpID = 2691
  1685. Attribute MoveTo.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1686. ' You can modify this sub to return the point before the move
  1687. ' by converting either the tempPoint(32-bit) or ret&(16-bit)
  1688. ' to a dwPoint and returning the dwPoint.
  1689. #If Win32 Then
  1690.     Dim tempPoint As POINTAPI
  1691.     Dim ret&
  1692.     
  1693.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1694.     ret& = apiMoveToEx(iHDC, pPoint.x, pPoint.y, tempPoint)
  1695.     If ret& = 0 Then RaiseHdcError
  1696. #Else
  1697.     Dim ret&
  1698.     
  1699.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1700.     ret& = apiMoveTo(iHDC, pPoint.x, pPoint.y)
  1701.     ' ret holds former point, not an error code
  1702. #End If
  1703. End Sub
  1704.  
  1705. Public Sub Pie(pPoint1 As dwPoint, pPoint2 As dwPoint, pPoint3 As dwPoint, pPoint4 As dwPoint)
  1706. Attribute Pie.VB_HelpID = 2591
  1707. Attribute Pie.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1708.     Dim ret&
  1709.     
  1710.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1711.     ret& = apiPie(iHDC, pPoint1.x, pPoint1.y, pPoint2.x, pPoint2.y, pPoint3.x, pPoint3.y, pPoint4.x, pPoint4.y)
  1712.     If ret& = 0 Then RaiseHdcError
  1713. End Sub
  1714.  
  1715. #If FlagMetaFile Then
  1716. Public Sub PlayEnhMetaFile(mf As dwMetaFile, rRect As dwRECT)
  1717. Attribute PlayEnhMetaFile.VB_HelpID = 2651
  1718. Attribute PlayEnhMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1719. #If Win32 Then
  1720.     Dim tempRect As RECT
  1721.     Dim ret&
  1722.     
  1723.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1724.     rRect.CopyToRECT agGetAddressForObject(tempRect.left)
  1725.     ret& = apiPlayEnhMetaFile(iHDC, mf.hMetaFile, tempRect)
  1726.     If ret& = 0 Then RaiseHdcError
  1727. #Else
  1728.     RaiseHdcError DWERR_NOTINWIN16
  1729. #End If
  1730. End Sub
  1731. #End If ' FlagMetafile
  1732.  
  1733. #If FlagPlayEnhMetaFileRecord = True And FlagMetaFile = True Then
  1734. Public Sub PlayEnhMetaFileRecord(lpHandleTable As dwHandleTable, lpEnhMetaRecord As dwEnhMetaRecord, nHandles As Long)
  1735. Attribute PlayEnhMetaFileRecord.VB_HelpID = 2652
  1736. Attribute PlayEnhMetaFileRecord.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1737. #If Win32 Then
  1738.     Dim tmpHTable As HANDLETABLE
  1739.     Dim tmpEMetaRec As ENHMETARECORD
  1740.     Dim ret&
  1741.     
  1742.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1743.     lpHandleTable.CopyToHANDLETABLE agGetAddressForObject(tmpHTable.ObjectHandle(0))
  1744.     lpEnhMetaRecord.CopyToENHMETARECORD agGetAddressForObject(tmpEMetaRec.iType)
  1745.     ret& = apiPlayEnhMetaFileRecord(iHDC, tmpHTable, tmpEMetaRec, nHandles)
  1746.     If ret& = 0 Then RaiseHdcError
  1747. #Else
  1748.     RaiseHdcError DWERR_NOTINWIN16
  1749. #End If
  1750. End Sub
  1751. #End If 'FlagPlayEnhMetaFileRecord, FlagMetafile
  1752.  
  1753. #If FlagMetaFile Then
  1754. Public Sub PlayMetaFile(mf As dwMetaFile)
  1755. Attribute PlayMetaFile.VB_HelpID = 2592
  1756. Attribute PlayMetaFile.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1757.     Dim ret&
  1758.     
  1759.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1760.     ret& = apiPlayMetaFile(iHDC, mf.hMetaFile)
  1761.     If ret& = 0 Then RaiseHdcError
  1762. End Sub
  1763. #End If ' FlagMetafile
  1764.  
  1765. #If FlagUseArrayNotCollection Then
  1766. Public Sub PolyBezier(lppt() As dwPoint, cPoints As Long)
  1767. Attribute PolyBezier.VB_HelpID = 2700
  1768. Attribute PolyBezier.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1769. End Sub
  1770. #If Win32 Then
  1771.     Dim tempPoints() As POINTAPI
  1772.     Dim ret&
  1773.     Dim i As Integer
  1774.  
  1775.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1776.     ReDim tempPoints(cPoints - 1)
  1777.     For i = 0 To cPoints - 1
  1778.         tempPoints(i).x = lppt(i).x
  1779.         tempPoints(i).y = lppt(i).y
  1780.     Next i
  1781.     ret& = apiPolyBezier(iHDC, tempPoints(0), cPoints)
  1782.     If ret& = 0 Then RaiseHdcError
  1783. #Else
  1784.     RaiseSysError DWERR_NOTINWIN16
  1785. #End If
  1786. End Sub
  1787. #Else ' use Collection
  1788. ' colPoints should be a collection of dwPoints
  1789. Public Sub PolyBezier(colPoints As Collection)
  1790. #If Win32 Then
  1791.     Dim tempPoints() As POINTAPI
  1792.     Dim ret&
  1793.     Dim i As Integer
  1794.     
  1795.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1796.     ReDim tempPoints(colPoints.count - 1)
  1797.     For i = 1 To colPoints.count
  1798.         tempPoints(i - 1).x = colPoints(i).x
  1799.         tempPoints(i - 1).y = colPoints(i).y
  1800.     Next i
  1801.     ret& = apiPolyBezier(iHDC, tempPoints(0), colPoints.count)
  1802.     If ret& = 0 Then RaiseHdcError
  1803. #Else
  1804.     RaiseHdcError DWERR_NOTINWIN16
  1805. #End If
  1806. End Sub
  1807. #End If ' FlagUseArrayNotCollection
  1808.  
  1809. #If FlagUseArrayNotCollection Then
  1810. Public Sub PolyBezierTo(lppt() As dwPoint, cPoints As Long)
  1811. Attribute PolyBezierTo.VB_HelpID = 2701
  1812. Attribute PolyBezierTo.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1813. #If Win32 Then
  1814.     Dim tempPoints() As POINTAPI
  1815.     Dim ret&
  1816.     Dim i As Integer
  1817.  
  1818.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1819.     ReDim tempPoints(cPoints - 1)
  1820.     For i = 0 To cPoints - 1
  1821.         tempPoints(i).x = lppt(i).x
  1822.         tempPoints(i).y = lppt(i).y
  1823.     Next i
  1824.     ret& = apiPolyBezierTo(iHDC, tempPoints(0), cPoints)
  1825.     If ret& = 0 Then RaiseHdcError
  1826. #End If
  1827. End Sub
  1828. #Else  ' use collection version
  1829. ' colPoints should be a collection of dwPoints
  1830. Public Sub PolyBezierTo(colPoints As Collection)
  1831. #If Win32 Then
  1832.     Dim tempPoints() As POINTAPI
  1833.     Dim ret&
  1834.     Dim i As Integer
  1835.     
  1836.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1837.     ReDim tempPoints(colPoints.count - 1)
  1838.     For i = 1 To colPoints.count
  1839.         tempPoints(i - 1).x = colPoints(i).x
  1840.         tempPoints(i - 1).y = colPoints(i).y
  1841.     Next i
  1842.     ret& = apiPolyBezierTo(iHDC, tempPoints(0), colPoints.count)
  1843.     If ret& = 0 Then RaiseHdcError
  1844. #End If
  1845. End Sub
  1846. #End If ' FlagUseArrayNotCollection
  1847.  
  1848. #If FlagUseArrayNotCollection Then
  1849. Public Sub PolyDraw(lppt() As dwPoint, lpbTypes() As Byte, cPoints As Long)
  1850. Attribute PolyDraw.VB_HelpID = 2680
  1851. Attribute PolyDraw.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1852. #If Win32 Then
  1853.     Dim tempPoints() As POINTAPI
  1854.     Dim ret&
  1855.     Dim i As Integer
  1856.  
  1857.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1858.     ReDim tempPoints(cPoints - 1)
  1859.     For i = 0 To cPoints - 1
  1860.         tempPoints(i).x = lppt(i).x
  1861.         tempPoints(i).y = lppt(i).y
  1862.     Next i
  1863.     ret& = apiPolyDraw(iHDC, tempPoints(0), lpbTypes(0), cPoints)
  1864.     If ret& = 0 Then RaiseHdcError
  1865. #Else
  1866.     RaiseSysError DWERR_NOTINWIN16
  1867. #End If
  1868. End Sub
  1869. #Else ' use collection version
  1870. ' colPoints should be a collection of dwPoints, colBytes a collection of Bytes
  1871. Public Sub PolyDraw(colPoints As Collection, colTypes As Collection)
  1872. #If Win32 Then
  1873.     Dim tempPoints() As POINTAPI
  1874.     Dim tempBytes() As Byte
  1875.     Dim ret&
  1876.     Dim i As Integer
  1877.     
  1878.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1879.     If colPoints.count <> colTypes.count Then RaiseHdcError DWERR_COUNTMISMATCH
  1880.     ReDim tempPoints(colPoints.count - 1)
  1881.     ReDim tempBytes(colPoints.count - 1)
  1882.     For i = 1 To colPoints.count
  1883.         tempPoints(i - 1).x = colPoints(i).x
  1884.         tempPoints(i - 1).y = colPoints(i).y
  1885.         tempBytes(i - 1) = colTypes(i)
  1886.     Next i
  1887.     ret& = apiPolyDraw(iHDC, tempPoints(0), tempBytes(0), colPoints.count)
  1888.     If ret& = 0 Then RaiseHdcError
  1889. #Else
  1890.     RaiseHdcError DWERR_NOTINWIN16
  1891. #End If
  1892. End Sub
  1893. #End If ' FlagUseArrayNotCollection
  1894.  
  1895. #If FlagUseArrayNotCollection Then
  1896. Public Sub Polygon(lppt() As dwPoint, ByVal cPoints)
  1897. Attribute Polygon.VB_HelpID = 2699
  1898. Attribute Polygon.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1899.     Dim tempPoints() As POINTAPI
  1900.     Dim ret&
  1901.     Dim i As Integer
  1902.  
  1903.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1904.     ReDim tempPoints(cPoints - 1)
  1905.     For i = 0 To cPoints - 1
  1906.         tempPoints(i).x = lppt(i).x
  1907.         tempPoints(i).y = lppt(i).y
  1908.     Next i
  1909.     ret& = apiPolygon(iHDC, tempPoints(0), cPoints)
  1910.     If ret& = 0 Then RaiseHdcError
  1911. End Sub
  1912. #Else ' use collection version
  1913. ' colPoints should be a collection of dwPoints
  1914. Public Sub Polygon(colPoints As Collection)
  1915.     Dim tempPoints() As POINTAPI
  1916.     Dim ret&
  1917.     Dim i As Integer
  1918.     
  1919.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1920.     ReDim tempPoints(colPoints.count - 1)
  1921.     For i = 1 To colPoints.count
  1922.         tempPoints(i - 1).x = colPoints(i).x
  1923.         tempPoints(i - 1).y = colPoints(i).y
  1924.     Next i
  1925.     ret& = apiPolygon(iHDC, tempPoints(0), colPoints.count)
  1926.     If ret& = 0 Then RaiseHdcError
  1927. End Sub
  1928. #End If ' FlagUseArrayNotCollection
  1929.  
  1930. #If FlagUseArrayNotCollection Then
  1931. Public Sub Polyline(lppt() As dwPoint, ByVal cPoints)
  1932. Attribute Polyline.VB_HelpID = 2698
  1933. Attribute Polyline.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1934.     Dim tempPoints() As POINTAPI
  1935.     Dim ret&
  1936.     Dim i As Integer
  1937.  
  1938.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1939.     ReDim tempPoints(cPoints - 1)
  1940.     For i = 0 To cPoints - 1
  1941.         tempPoints(i).x = lppt(i).x
  1942.         tempPoints(i).y = lppt(i).y
  1943.     Next i
  1944.     ret& = apiPolyline(iHDC, tempPoints(0), cPoints)
  1945.     If ret& = 0 Then RaiseHdcError
  1946. End Sub
  1947. #Else ' use collection version
  1948. ' colPoints should be a collection of dwPoints
  1949. Public Sub Polyline(colPoints As Collection)
  1950.     Dim tempPoints() As POINTAPI
  1951.     Dim ret&
  1952.     Dim i As Integer
  1953.     
  1954.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1955.     ReDim tempPoints(colPoints.count - 1)
  1956.     For i = 1 To colPoints.count
  1957.         tempPoints(i - 1).x = colPoints(i).x
  1958.         tempPoints(i - 1).y = colPoints(i).y
  1959.     Next i
  1960.     ret& = apiPolyline(iHDC, tempPoints(0), colPoints.count)
  1961.     If ret& = 0 Then RaiseHdcError
  1962. End Sub
  1963. #End If ' FlagUseArrayNotCollection
  1964.  
  1965. #If FlagUseArrayNotCollection Then
  1966. Public Sub PolylineTo(lppt() As dwPoint, cPoints As Long)
  1967. Attribute PolylineTo.VB_HelpID = 2702
  1968. Attribute PolylineTo.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1969. #If Win32 Then
  1970.     Dim tempPoints() As POINTAPI
  1971.     Dim ret&
  1972.     Dim i As Integer
  1973.  
  1974.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1975.     ReDim tempPoints(cPoints - 1)
  1976.     For i = 0 To cPoints - 1
  1977.         tempPoints(i).x = lppt(i).x
  1978.         tempPoints(i).y = lppt(i).y
  1979.     Next i
  1980.     ret& = apiPolylineTo(iHDC, tempPoints(0), cPoints)
  1981.     If ret& = 0 Then RaiseHdcError
  1982. #Else
  1983.     RaiseSysError DWERR_NOTINWIN16
  1984. #End If
  1985. End Sub
  1986. #Else ' use collection version
  1987. ' colPoints should be a collection of dwPoints
  1988. Public Sub PolylineTo(colPoints As Collection)
  1989. #If Win32 Then
  1990.     Dim tempPoints() As POINTAPI
  1991.     Dim ret&
  1992.     Dim i As Integer
  1993.     
  1994.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  1995.     ReDim tempPoints(colPoints.count - 1)
  1996.     For i = 1 To colPoints.count
  1997.         tempPoints(i - 1).x = colPoints(i).x
  1998.         tempPoints(i - 1).y = colPoints(i).y
  1999.     Next i
  2000.     ret& = apiPolylineTo(iHDC, tempPoints(0), colPoints.count)
  2001.     If ret& = 0 Then RaiseHdcError
  2002. #Else
  2003.     RaiseHdcError DWERR_NOTINWIN16
  2004. #End If
  2005. End Sub
  2006. #End If ' FlagUseArrayNotCollection
  2007.  
  2008. #If FlagUseArrayNotCollection Then
  2009. Public Sub PolyPolyline(lppt() As dwPoint, lpPolyPoints() As Long, cPolygons As Long)
  2010. Attribute PolyPolyline.VB_HelpID = 2658
  2011. Attribute PolyPolyline.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2012. #If Win32 Then
  2013.     Dim tempPoints() As POINTAPI
  2014.     Dim ret&
  2015.     Dim i As Integer
  2016.     Dim cPoints As Long
  2017.  
  2018.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2019.     cPoints = UBound(lppt) + 1
  2020.     ReDim tempPoints(cPoints - 1)
  2021.     For i = 0 To cPoints - 1
  2022.         tempPoints(i).x = lppt(i).x
  2023.         tempPoints(i).y = lppt(i).y
  2024.     Next i
  2025.     ret& = apiPolyPolyline(iHDC, tempPoints(0), lpPolyPoints(0), cPolygons)
  2026.     If ret& = 0 Then RaiseHdcError
  2027. #Else
  2028.     RaiseSysError DWERR_NOTINWIN16
  2029. #End If
  2030. End Sub
  2031. #Else ' use collection version
  2032. ' colPoints should be a collection of dwPoints, colPolyPoints of Longs
  2033. Public Sub PolyPolyline(colPoints As Collection, colPolyPoints As Collection, cPolygons As Long)
  2034. #If Win32 Then
  2035.     Dim tempPoints() As POINTAPI
  2036.     Dim tempLongs() As Long
  2037.     Dim ret&
  2038.     Dim i As Integer
  2039.     Dim cPoints As Long
  2040.     
  2041.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2042.     cPoints = colPoints.count
  2043.     ReDim tempPoints(cPoints - 1)
  2044.     ReDim tempLongs(cPoints - 1)
  2045.     For i = 1 To cPoints
  2046.         tempPoints(i - 1).x = colPoints(i).x
  2047.         tempPoints(i - 1).y = colPoints(i).y
  2048.         tempLongs(i - 1) = colPolyPoints(i)
  2049.     Next i
  2050.     ret& = apiPolyPolyline(iHDC, tempPoints(0), tempLongs(0), cPolygons)
  2051.     If ret& = 0 Then RaiseHdcError
  2052. #Else
  2053.     RaiseHdcError DWERR_NOTINWIN16
  2054. #End If
  2055. End Sub
  2056. #End If 'FlagUseArrayNotCollection
  2057.  
  2058. Public Sub Rectangle(pRect As dwRECT)
  2059. Attribute Rectangle.VB_HelpID = 2599
  2060. Attribute Rectangle.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2061.     Dim ret&
  2062.     
  2063.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2064.     ret& = apiRectangle(iHDC, pRect.left, pRect.top, pRect.right, pRect.bottom)
  2065.     If ret& = 0 Then RaiseHdcError
  2066. End Sub
  2067.  
  2068. Public Sub RoundRect(pRect As dwRECT, ByVal X3, ByVal Y3)
  2069. Attribute RoundRect.VB_HelpID = 2604
  2070. Attribute RoundRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2071.     Dim ret&
  2072.     
  2073.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2074.     ret& = apiRoundRect(iHDC, pRect.left, pRect.top, pRect.right, pRect.bottom, X3, Y3)
  2075.     If ret& = 0 Then RaiseHdcError
  2076. End Sub
  2077.  
  2078. Public Function SetBkColor(crColor As Long) As Long
  2079. Attribute SetBkColor.VB_HelpID = 2612
  2080. Attribute SetBkColor.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2081.     Dim ret&
  2082.     
  2083.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2084.     ret& = apiSetBkColor(iHDC, crColor)
  2085.     If ret& = CLR_INVALID Then RaiseHdcError
  2086.     SetBkColor = ret&
  2087. End Function
  2088.  
  2089. Public Sub SetArcDirection(ArcDirection As Long)
  2090. Attribute SetArcDirection.VB_HelpID = 2682
  2091. Attribute SetArcDirection.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2092. #If Win32 Then
  2093.     Dim ret&
  2094.     
  2095.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2096.     ret& = apiSetArcDirection(iHDC, ArcDirection)
  2097.     If ret& = 0 Then RaiseHdcError
  2098. #Else
  2099.     RaiseHdcError DWERR_NOTINWIN16
  2100. #End If
  2101. End Sub
  2102.  
  2103. Public Function SetBkMode(ByVal nBkMode) As Long
  2104. Attribute SetBkMode.VB_HelpID = 2613
  2105. Attribute SetBkMode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2106.     Dim ret&
  2107.     
  2108.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2109.     ret& = apiSetBkMode(iHDC, nBkMode)
  2110.     If ret& = 0 Then RaiseHdcError
  2111.     SetBkMode = ret&
  2112. End Function
  2113.  
  2114. Public Sub SetBrushOrg(lppt As dwPoint)
  2115. Attribute SetBrushOrg.VB_HelpID = 2712
  2116. Attribute SetBrushOrg.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2117. #If Win32 Then
  2118.     Dim junk As POINTAPI
  2119.     Dim ret&
  2120.     
  2121.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2122.     ret& = apiSetBrushOrgEx(iHDC, lppt.x, lppt.y, junk)
  2123.     If ret& = 0 Then RaiseHdcError
  2124. #Else
  2125.     Dim ret&
  2126.     
  2127.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2128.     ret& = apiSetBrushOrg(iHDC, lppt.x, lppt.y)
  2129. #End If
  2130. End Sub
  2131.  
  2132. Public Sub SetMiterLimit(eNewLimit As Single, peOldLimit As Single)
  2133. Attribute SetMiterLimit.VB_HelpID = 2683
  2134. Attribute SetMiterLimit.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2135. #If Win32 Then
  2136.     Dim ret&
  2137.     
  2138.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2139.     ret& = apiSetMiterLimit(iHDC, eNewLimit, peOldLimit)
  2140.     If ret& = 0 Then RaiseHdcError
  2141. #Else
  2142.     RaiseHdcError DWERR_NOTINWIN16
  2143. #End If
  2144. End Sub
  2145.  
  2146. Public Function SetPixel(pPoint As dwPoint, crColor As Long) As Long
  2147. Attribute SetPixel.VB_HelpID = 2623
  2148. Attribute SetPixel.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2149.     Dim ret&
  2150.     
  2151.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2152.     ret& = apiSetPixel(iHDC, pPoint.x, pPoint.y, crColor)
  2153.     If ret& = -1 Then RaiseHdcError
  2154.     SetPixel = ret&
  2155. End Function
  2156.  
  2157. Public Sub SetPixelV(pPoint As dwPoint, crColor As Long)
  2158. Attribute SetPixelV.VB_HelpID = 2624
  2159. Attribute SetPixelV.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2160. #If Win32 Then
  2161.     Dim ret&
  2162.     
  2163.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2164.     ret& = apiSetPixelV(iHDC, pPoint.x, pPoint.y, crColor)
  2165.     If ret& = 0 Then RaiseHdcError
  2166. #Else
  2167.     RaiseHdcError DWERR_NOTINWIN16
  2168. #End If
  2169. End Sub
  2170.  
  2171. Public Function SetPolyFillMode(ByVal nPolyFillMode As Long) As Long
  2172. Attribute SetPolyFillMode.VB_HelpID = 2625
  2173. Attribute SetPolyFillMode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2174.     Dim ret&
  2175.     
  2176.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2177.     ret& = apiSetPolyFillMode(iHDC, nPolyFillMode)
  2178.     If ret& = 0 Then RaiseHdcError
  2179.     SetPolyFillMode = ret&
  2180. End Function
  2181.  
  2182. Public Function SetROP2(nDrawMode As Long) As Long
  2183. Attribute SetROP2.VB_HelpID = 2629
  2184. Attribute SetROP2.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2185.     Dim ret&
  2186.     
  2187.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2188.     ret& = apiSetROP2(iHDC, nDrawMode)
  2189.     If ret& = 0 Then RaiseHdcError
  2190.     SetROP2 = ret&
  2191. End Function
  2192.  
  2193. Public Sub StrokeAndFillPath()
  2194. Attribute StrokeAndFillPath.VB_HelpID = 2684
  2195. Attribute StrokeAndFillPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2196. #If Win32 Then
  2197.     Dim ret&
  2198.     
  2199.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2200.     ret& = apiStrokeAndFillPath(iHDC)
  2201.     If ret& = 0 Then RaiseHdcError
  2202. #Else
  2203.     RaiseHdcError DWERR_NOTINWIN16
  2204. #End If
  2205. End Sub
  2206.  
  2207. Public Sub StrokePath()
  2208. Attribute StrokePath.VB_HelpID = 2685
  2209. Attribute StrokePath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2210. #If Win32 Then
  2211.     Dim ret&
  2212.     
  2213.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2214.     ret& = apiStrokePath(iHDC)
  2215.     If ret& = 0 Then RaiseHdcError
  2216. #Else
  2217.     RaiseHdcError DWERR_NOTINWIN16
  2218. #End If
  2219. End Sub
  2220.  
  2221. Public Sub WidenPath()
  2222. Attribute WidenPath.VB_HelpID = 2686
  2223. Attribute WidenPath.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2224. #If Win32 Then
  2225.     Dim ret&
  2226.     
  2227.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2228.     ret& = apiWidenPath(iHDC)
  2229.     If ret& = 0 Then RaiseHdcError
  2230. #Else
  2231.     RaiseHdcError DWERR_NOTINWIN16
  2232. #End If
  2233. End Sub
  2234.  
  2235. Public Sub BitBlt(XDest As Long, YDest As Long, Width As Long, Height As Long, source As dwDeviceContext, XSrc As Long, YSrc As Long, operation As Long)
  2236. Attribute BitBlt.VB_HelpID = 2484
  2237. Attribute BitBlt.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2238.     Dim ret&
  2239.     If source.hDC = 0 Or iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2240.     ret& = apiBitBlt(iHDC, XDest, YDest, Width, Height, source.hDC, XSrc, YSrc, operation)
  2241.     If ret& = 0 Then RaiseHdcError
  2242. End Sub
  2243.  
  2244. Public Sub StretchBlt(XDest As Long, YDest As Long, Width As Long, Height As Long, source As dwDeviceContext, XSrc As Long, YSrc As Long, srcWidth As Long, srcHeight As Long, operation As Long)
  2245. Attribute StretchBlt.VB_HelpID = 2626
  2246. Attribute StretchBlt.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2247.     Dim ret&
  2248.     If source.hDC = 0 Or iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2249.     ret& = apiStretchBlt(iHDC, XDest, YDest, Width, Height, source.hDC, XSrc, YSrc, srcWidth, srcHeight, operation)
  2250.     If ret& = 0 Then RaiseHdcError
  2251. End Sub
  2252.  
  2253. Public Sub PatBlt(XDest As Long, YDest As Long, Width As Long, Height As Long, operation As Long)
  2254. Attribute PatBlt.VB_HelpID = 2590
  2255. Attribute PatBlt.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2256.     Dim ret&
  2257.     If iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2258.     ret& = apiPatBlt(iHDC, XDest, YDest, Width, Height, operation)
  2259.     If ret& = 0 Then RaiseHdcError
  2260. End Sub
  2261.  
  2262. #If FlagBitmap = True Then
  2263. Public Sub MaskBlt(XDest As Long, YDest As Long, Width As Long, Height As Long, source As dwDeviceContext, XSrc As Long, YSrc As Long, myBitmap As dwBitmap, Xbitmap As Long, Ybitmap As Long, operation As Long)
  2264. Attribute MaskBlt.VB_HelpID = 2586
  2265. Attribute MaskBlt.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2266. #If Win32 Then
  2267.     Dim ret&
  2268.     If source.hDC = 0 Or iHDC = 0 Then RaiseHdcError DWERR_UNINITIALIZED
  2269.     ret& = apiMaskBlt(iHDC, XDest, YDest, Width, Height, source.hDC, XSrc, YSrc, myBitmap.hBitmap, Xbitmap, Ybitmap, operation)
  2270.     If ret& = 0 Then RaiseHdcError
  2271. #Else
  2272.     RaiseHdcError DWERR_NOTINWIN16
  2273. #End If
  2274. End Sub
  2275. #End If 'FlagBitMap
  2276.  
  2277. Property Get SRCAND() As Long
  2278.     SRCAND = &H8800C6
  2279. End Property
  2280.  
  2281. Property Get SRCCOPY() As Long
  2282.     SRCCOPY = &HCC0020
  2283. End Property
  2284.  
  2285. Property Get SRCERASE() As Long
  2286.     SRCERASE = &H440328
  2287. End Property
  2288.  
  2289. Property Get SRCINVERT() As Long
  2290.     SRCINVERT = &H660046
  2291. End Property
  2292.  
  2293. Property Get SRCPAINT() As Long
  2294.     SRCPAINT = &HEE0086
  2295. End Property
  2296.  
  2297.  
  2298. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  2299. ' The following is for compatibility with the
  2300. ' API Foundation Library Standard.  It is not a full
  2301. ' implementation, as this library was completed before
  2302. ' the final version of the standard was completed.
  2303. ' There are also a number of functions that are not
  2304. ' completed for lack of time or because adequate
  2305. ' documentation was not provided.  The standard
  2306. ' may change at any time after this libray is released,
  2307. ' so the functions below may not be correct.
  2308.  
  2309. ' The "Attach" functions are ways of setting up the
  2310. ' class.  Most of the functions below are the same
  2311. ' as the API functions above, but are renamed for
  2312. ' some reason.
  2313.  
  2314. Public Sub Attach(vNewValue)
  2315.     If DCsource <> 3 Then ' if not a metafile
  2316.         If apiGetMapMode(vNewValue) = 0 Then RaiseHdcError 380
  2317.         DCsource = 2    ' Direct setting
  2318.         InitialSaveDC = apiSaveDC(iHDC)    ' Save initial state
  2319.         ClearDC         ' Clear existing DC info
  2320.     End If
  2321.     iHDC = vNewValue
  2322.     DeviceCaps.InitDevCaps iHDC
  2323. End Sub
  2324.  
  2325. Public Sub AttachWindow(wnd As dwWindow)
  2326.     GetWindowDC wnd
  2327. End Sub
  2328.  
  2329. Public Function ArcDirection() As Integer
  2330. Attribute ArcDirection.VB_HelpID = 2689
  2331. Attribute ArcDirection.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2332.     ArcDirection = GetArcDirection()
  2333. End Function
  2334.  
  2335. Public Function CreateCompatible() As dwDeviceContext
  2336. Attribute CreateCompatible.VB_HelpID = 2495
  2337. Attribute CreateCompatible.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2338.     Set CreateCompatible = CreateCompatibleDC()
  2339. End Function
  2340.  
  2341. Public Sub Delete()
  2342.     ClearDC
  2343. End Sub
  2344.  
  2345. Public Sub Detach()
  2346.     ClearDC
  2347. End Sub
  2348.  
  2349. Public Function DeviceCapability(capabilities As Long) As Long
  2350. Attribute DeviceCapability.VB_HelpID = 2522
  2351. Attribute DeviceCapability.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  2352.     DeviceCapability = DeviceCaps.GetCapability(capabilities)
  2353. End Function
  2354.  
  2355. Public Sub DrawAngleArc(pPoint As dwPoint, dwRadius As Long, eStartAngle As Double, eSweepAngle As Double)
  2356.     AngleArc pPoint, dwRadius, eStartAngle, eSweepAngle
  2357. End Sub
  2358.  
  2359. Public Sub DrawArc(rRect As dwRECT, StartPoint As dwPoint, EndPoint As dwPoint)
  2360.     Dim tmpPoint1 As New dwPoint
  2361.     Dim tmpPoint2 As New dwPoint
  2362.     
  2363.     tmpPoint1.x = rRect.left
  2364.     tmpPoint1.y = rRect.top
  2365.     tmpPoint2.x = rRect.right
  2366.     tmpPoint2.y = rRect.bottom
  2367.     Arc tmpPoint1, tmpPoint2, StartPoint, EndPoint
  2368. End Sub
  2369.  
  2370. Public Sub DrawArcTo(rRect As dwRECT, StartPoint As dwPoint, EndPoint As dwPoint)
  2371.     Dim tmpPoint1 As New dwPoint
  2372.     Dim tmpPoint2 As New dwPoint
  2373.     
  2374.     tmpPoint1.x = rRect.left
  2375.     tmpPoint1.y = rRect.top
  2376.     tmpPoint2.x = rRect.right
  2377.     tmpPoint2.y = rRect.bottom
  2378.     ArcTo tmpPoint1, tmpPoint2, StartPoint, EndPoint
  2379. End Sub
  2380.  
  2381. Public Sub DrawChord(rRect As dwRECT, StartPoint As dwPoint, EndPoint As dwPoint)
  2382.     Dim tmpPoint1 As New dwPoint
  2383.     Dim tmpPoint2 As New dwPoint
  2384.     
  2385.     tmpPoint1.x = rRect.left
  2386.     tmpPoint1.y = rRect.top
  2387.     tmpPoint2.x = rRect.right
  2388.     tmpPoint2.y = rRect.bottom
  2389.     Chord tmpPoint1, tmpPoint2, StartPoint, EndPoint
  2390. End Sub
  2391.  
  2392. Public Sub DrawEllipse(rRect As dwRECT)
  2393.     Ellipse rRect
  2394. End Sub
  2395.  
  2396. Public Sub DrawLine(FromPoint As dwPoint, ToPoint As dwPoint)
  2397.     MoveTo FromPoint
  2398.     LineTo ToPoint
  2399. End Sub
  2400.  
  2401. Public Sub DrawLineTo(ToPoint As dwPoint)
  2402.     LineTo ToPoint
  2403. End Sub
  2404.  
  2405. Public Sub DrawPie(rRect As dwRECT, StartPoint As dwPoint, EndPoint As dwPoint)
  2406.     Dim tmpPoint1 As New dwPoint
  2407.     Dim tmpPoint2 As New dwPoint
  2408.     
  2409.     tmpPoint1.x = rRect.left
  2410.     tmpPoint1.y = rRect.top
  2411.     tmpPoint2.x = rRect.right
  2412.     tmpPoint2.y = rRect.bottom
  2413.     Pie tmpPoint1, tmpPoint2, StartPoint, EndPoint
  2414. End Sub
  2415.  
  2416. Public Sub DrawPolyBezier(points As Collection)
  2417.     PolyBezier points
  2418. End Sub
  2419.  
  2420. Public Sub DrawPolyBezierTo(points As Collection)
  2421.     PolyBezierTo points
  2422. End Sub
  2423.  
  2424. Public Sub DrawPolygon(points As Collection)
  2425.     Polygon points
  2426. End Sub
  2427.  
  2428. Public Sub DrawPolyline(points As Collection)
  2429.     Polyline points
  2430. End Sub
  2431.  
  2432. Public Sub DrawPloylineTo(points As Collection)
  2433.     PolylineTo points
  2434. End Sub
  2435.  
  2436. Public Sub DrawRectangle(rRect As dwRECT)
  2437.     Rectangle rRect
  2438. End Sub
  2439.  
  2440. Public Sub DrawRoundedRectangle(rRect As dwRECT, ByVal ElipseWidth, ByVal ElipseHeight)
  2441.     RoundRect rRect, ElipseWidth, ElipseHeight
  2442. End Sub
  2443.  
  2444. Public Sub FillRectangle(rRect As dwRECT, hBrush As dwBrush)
  2445.     FillRect rRect, hBrush
  2446. End Sub
  2447.  
  2448. Public Sub FrameRectangle(rRect As dwRECT, hBrush As dwBrush)
  2449.     FrameRect rRect, hBrush
  2450. End Sub
  2451.  
  2452. Public Sub FrameRegion(hRgn As dwRegion, hBrush As dwBrush, ByVal nWidth, ByVal nHeight)
  2453.     FrameRgn hRgn, hBrush, nWidth, nHeight
  2454. End Sub
  2455.  
  2456. Public Sub InvertRectangle(rRect As dwRECT)
  2457.     InvertRect rRect
  2458. End Sub
  2459.  
  2460. Public Sub InvertRegion(hRgn As dwRegion)
  2461.     InvertRgn hRgn
  2462. End Sub
  2463.  
  2464. Public Sub OffsetViewportOrigin(ByVal nX, ByVal nY)
  2465.     Dim tmpPoint As dwPoint
  2466.     
  2467.     OffsetViewportOrgEx nX, nY, tmpPoint
  2468. End Sub
  2469.  
  2470. Public Sub PaintRegion(hRgn As dwRegion)
  2471.     PaintRgn hRgn
  2472. End Sub
  2473.  
  2474. Public Property Get PolygonFillMode() As Long
  2475.     PolygonFillMode = GetPolyFillMode()
  2476. End Property
  2477.  
  2478. Public Property Let PolygonFillMode(ByVal vNewValue As Long)
  2479.     Call SetPolyFillMode(vNewValue)
  2480. End Property
  2481.  
  2482. Public Sub Restore(ByVal nSavedDC)
  2483.     RestoreDC nSavedDC
  2484. End Sub
  2485.  
  2486. Public Function Save() As Long
  2487.     SaveDC
  2488.     Save = True ' SaveDC will cause a VB error if there is a problem.
  2489. End Function
  2490.  
  2491. ' You can replace these dwPoints with dwSizes to match the
  2492. ' API Foundation Library Standard without other modification.
  2493. Public Function ScaleViewportExtent(ByVal nXnum, ByVal nXdenom, ByVal nYnum, ByVal nYdenom) As dwPoint
  2494.     Dim pSize As dwPoint
  2495.     
  2496.     ScaleViewportExtEx nXnum, nXdenom, nYnum, nYdenom, pSize
  2497.     Set ScaleViewportExtent = pSize
  2498. End Function
  2499.  
  2500. ' You can replace these dwPoints with dwSizes to match the
  2501. ' API Foundation Library Standard without other modification.
  2502. Public Function ScaleWindowExtent(ByVal nXnum, ByVal nXdenom, ByVal nYnum, ByVal nYdenom) As dwPoint
  2503.     Dim pSize As dwPoint
  2504.  
  2505.     ScaleWindowExtEx nXnum, nXdenom, nYnum, nYdenom, pSize
  2506.     Set ScaleWindowExtent = pSize
  2507. End Function
  2508.  
  2509. #If FlagBitmap Then
  2510. Public Sub SelectBitmap(bm As dwBitmap)
  2511.     SelectObjectBitmap bm
  2512. End Sub
  2513. #End If ' FlagBitmap
  2514.  
  2515. Public Sub SelectBrush(br As dwBrush)
  2516.     SelectObjectBrush br
  2517. End Sub
  2518.  
  2519. Public Sub SelectPen(pn As dwPen)
  2520.     SelectObjectPen pn
  2521. End Sub
  2522.  
  2523. Public Property Get ViewportExtent() As dwPoint
  2524.     Set ViewportExtent = GetViewportExtEx()
  2525. End Property
  2526.  
  2527. Public Property Let ViewportExtent(vNewValue As dwPoint)
  2528.     Dim tmpPoint As dwPoint
  2529.     SetViewportExtEx vNewValue.x, vNewValue.y, tmpPoint
  2530. End Property
  2531.  
  2532. Public Property Get ViewportOrigin() As dwPoint
  2533.     Set ViewportOrigin = GetViewportOrgEx()
  2534. End Property
  2535.  
  2536. Public Property Let ViewportOrigin(vNewValue As dwPoint)
  2537.     Dim tmpPoint As dwPoint
  2538.     SetViewportOrgEx vNewValue.x, vNewValue.y, tmpPoint
  2539. End Property
  2540.  
  2541. Public Property Get WindowExtent() As dwPoint
  2542.     Set WindowExtent = GetWindowExtEx()
  2543. End Property
  2544.  
  2545. Public Property Let WindowExtent(vNewValue As dwPoint)
  2546.     Dim tmpPoint As dwPoint
  2547.     SetWindowExtEx vNewValue.x, vNewValue.y, tmpPoint
  2548. End Property
  2549.  
  2550. Public Property Get WindowOrigin() As dwPoint
  2551.     Set WindowOrigin = GetWindowOrgEx()
  2552. End Property
  2553.  
  2554. Public Property Let WindowOrigin(vNewValue As dwPoint)
  2555.     Dim tmpPoint As dwPoint
  2556.     SetWindowOrgEx vNewValue.x, vNewValue.y, tmpPoint
  2557. End Property
  2558.  
  2559.