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 / dwwindow.cls < prev    next >
Encoding:
Text File  |  1996-04-23  |  54.4 KB  |  1,284 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "dwWindow"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. ' Class dwWindow
  11. ' Hwnd control and configuration class
  12. ' Copyright (c) 1996 by Desaware Inc.
  13. ' Part of the Desaware API Classes Library
  14. ' All rights reserved
  15.  
  16. ' These flags will activate certain functions that require
  17. ' classes that most functions do not need.  If you do not
  18. ' need to use a function that is triggered by a flag, you
  19. ' can set the flag to False, and prevent an unneeded class
  20. ' from being loaded.
  21. #Const FlagGetDC = True  ' uses dwDeviceContext
  22. #Const FlagRegion = True  ' uses dwRegion
  23.  
  24. Private iHwnd As Long ' Window handle assigned to this object
  25.  
  26. Private iLeft As Long ' These are for API Foundation Library Standard compatibility
  27. Private iTop As Long
  28. Private iWidth As Long
  29. Private iHeight As Long
  30.  
  31.  
  32. '********************Located In Chapter 5 Function Index *************************
  33.  
  34. #If Win32 Then
  35. Private Declare Function apiIsWindowEnabled& Lib "user32" Alias "IsWindowEnabled" (ByVal hwnd As Long)
  36. Private Declare Function apiGetDesktopWindow& Lib "user32" Alias "GetDesktopWindow" ()
  37. Private Declare Function apiGetForegroundWindow& Lib "user32" Alias "GetForegroundWindow" ()
  38. Private Declare Function apiGetParent& Lib "user32" Alias "GetParent" (ByVal hwnd As Long)
  39. Private Declare Function apiGetTopWindow& Lib "user32" Alias "GetTopWindow" (ByVal hwnd As Long)
  40. Private Declare Function apiGetWindow& Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long)
  41. Private Declare Function apiGetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long)
  42. Private Declare Function apiGetWindowRect& Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT)
  43. Private Declare Function apiIsWindowUnicode& Lib "user32" Alias "IsWindowUnicode" (ByVal hwnd As Long)
  44. Private Declare Function apiIsWindowVisible& Lib "user32" Alias "IsWindowVisible" (ByVal hwnd As Long)
  45. Private Declare Function apiInvalidateRect& Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long)
  46. Private Declare Function apiInvalidateRectBynum& Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, ByVal lpRect As Long, ByVal bErase As Long)
  47. Private Declare Function apiIsChild& Lib "user32" Alias "IsChild" (ByVal hWndParent As Long, ByVal hwnd As Long)
  48. Private Declare Function apiIsIconic& Lib "user32" Alias "IsIconic" (ByVal hwnd As Long)
  49. Private Declare Function apiIsZoomed& Lib "user32" Alias "IsZoomed" (ByVal hwnd As Long)
  50. Private Declare Function apiLockWindowUpdate& Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long)
  51. Private Declare Function apiMoveWindow& Lib "user32" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long)
  52. Private Declare Function apiOpenIcon& Lib "user32" Alias "OpenIcon" (ByVal hwnd As Long)
  53. Private Declare Function apiRedrawWindow& Lib "user32" Alias "RedrawWindow" (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hRgnUpdate As Long, ByVal fuRedraw As Long)
  54. Private Declare Function apiReleaseCapture& Lib "user32" Alias "ReleaseCapture" ()
  55. Private Declare Function apiScreenToClient& Lib "user32" Alias "ScreenToClient" (ByVal hwnd As Long, lpPoint As POINTAPI)
  56. Private Declare Function apiScrollWindow& Lib "user32" Alias "ScrollWindow" (ByVal hwnd As Long, ByVal XAmount As Long, ByVal YAmount As Long, lpRect As RECT, lpClipRect As RECT)
  57. Private Declare Function apiScrollWindowByval& Lib "user32" Alias "ScrollWindow" (ByVal hwnd As Long, ByVal XAmount As Long, ByVal YAmount As Long, ByVal lpRect As Long, ByVal lpClipRect As Long)
  58. Private Declare Function apiScrollWindowEx& Lib "user32" Alias "ScrollWindowEx" (ByVal hwnd As Long, ByVal dx As Long, ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hRgnUpdate As Long, lprcUpdate As RECT, ByVal fuScroll As Long)
  59. Private Declare Function apiScrollWindowExByval& Lib "user32" Alias "ScrollWindowEx" (ByVal hwnd As Long, ByVal dx As Long, ByVal dy As Long, ByVal lprcScroll As Long, ByVal lprcClip As Long, ByVal hRgnUpdate As Long, ByVal lprcUpdate As Long, ByVal fuScroll As Long)
  60. Private Declare Function apiSetActiveWindow& Lib "user32" Alias "SetActiveWindow" (ByVal hwnd As Long)
  61. Private Declare Function apiSetCapture& Lib "user32" Alias "SetCapture" (ByVal hwnd As Long)
  62. Private Declare Function apiSetFocus& Lib "user32" Alias "SetFocus" (ByVal hwnd As Long)
  63. Private Declare Function apiSetForegroundWindow& Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long)
  64. Private Declare Function apiSetParent& Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long)
  65. Private Declare Function apiSetWindowPos& Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
  66. Private Declare Function apiSetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
  67. Private Declare Function apiSetWindowText& Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String)
  68. Private Declare Function apiSetWindowWord% Lib "user32" Alias "SetWindowWord" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Integer)
  69. Private Declare Function apiShowOwnedPopups& Lib "user32" Alias "ShowOwnedPopups" (ByVal hwnd As Long, ByVal fshow As Long)
  70. Private Declare Function apiShowWindow& Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long)
  71. Private Declare Function apiShowWindowAsync& Lib "user32" Alias "ShowWindowAsync" (ByVal hwnd As Long, ByVal nCmdShow As Long)
  72. Private Declare Function apiValidateRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
  73. Private Declare Function apiValidateRectBynum& Lib "user32" Alias "ValidateRect" (ByVal hwnd As Long, ByVal lpRect As Long)
  74. Private Declare Function apiArrangeIconicWindows& Lib "user32" Alias "ArrangeIconicWindows" (ByVal hwnd As Long)
  75. Private Declare Function apiChildWindowFromPoint& Lib "user32" Alias "ChildWindowFromPoint" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long)
  76. Private Declare Function apiChildWindowFromPointEx& Lib "user32" Alias "ChildWindowFromPointEx" (ByVal hWndParent As Long, ByVal ptx As Long, ByVal pty As Long, ByVal uFlags As Long)
  77. Private Declare Function apiGetClassName& Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
  78. Private Declare Function apiGetClassLong& Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long)
  79. Private Declare Function apiFlashWindow& Lib "user32" Alias "FlashWindow" (ByVal hwnd As Long, ByVal bInvert As Long)
  80.  
  81. Private Declare Function apiFindWindowEx& Lib "user32" Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String)
  82. Private Declare Function apiEnableWindow& Lib "user32" Alias "EnableWindow" (ByVal hwnd As Long, ByVal fEnable As Long)
  83. Private Declare Function apiCloseWindow& Lib "user32" Alias "CloseWindow" (ByVal hwnd As Long)
  84. Private Declare Function apiClientToScreen& Lib "user32" Alias "ClientToScreen" (ByVal hwnd As Long, lpPoint As POINTAPI)
  85. Private Declare Function apiDestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hwnd As Long) As Boolean
  86. Private Declare Function apiBringWindowToTop& Lib "user32" Alias "BringWindowToTop" (ByVal hwnd As Long)
  87. Private Declare Function apiWindowFromPoint& Lib "user32" Alias "WindowFromPoint" (ByVal x As Long, ByVal y As Long)
  88.  
  89. Private Declare Function apiGetClientRect& Lib "user32" Alias "GetClientRect" (ByVal hwnd As Long, lpRect As RECT)
  90. Private Declare Function apiGetWindowText& Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long)
  91. Private Declare Function apiGetWindowTextLength& Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long)
  92. Private Declare Function apiIsWindow& Lib "user32" Alias "IsWindow" (ByVal hwnd As Long)
  93. Private Declare Function apiUpdateWindow& Lib "user32" Alias "UpdateWindow" (ByVal hwnd As Long)
  94.  
  95. Private Declare Function apiInvalidateRgn& Lib "user32" Alias "InvalidateRgn" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bErase As Long)
  96. Private Declare Function apiSendMessage& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal nMsg As Integer, ByVal wParam As Long, ByVal lParam As Long)
  97. Private Declare Sub apiDragAcceptFiles Lib "shell32.dll" Alias "DragAcceptFiles" (ByVal hwnd As Long, ByVal accept As Boolean)
  98. #Else
  99. Private Declare Function apiIsWindowEnabled% Lib "user" Alias "IsWindowEnabled" (ByVal hwnd As Integer)
  100. Private Declare Function apiGetParent% Lib "user" Alias "GetParent" (ByVal hwnd As Integer)
  101. Private Declare Function apiGetDesktopWindow% Lib "user" Alias "GetDesktopWindow" ()
  102. Private Declare Function apiGetTopWindow% Lib "user" Alias "GetTopWindow" (ByVal hwnd As Integer)
  103. Private Declare Function apiGetWindow% Lib "user" Alias "GetWindow" (ByVal hwnd As Integer, ByVal wCmd As Integer)
  104. Private Declare Function apiGetWindowLong& Lib "user" Alias "GetWindowLong" (ByVal hwnd As Integer, ByVal nIndex As Integer)
  105. Private Declare Sub apiGetWindowRect Lib "user" Alias "GetWindowRect" (ByVal hwnd As Integer, lpRect As RECT)
  106. 'Function IsWindowUnicode is not available in the WIN16 API.
  107. Private Declare Function apiIsWindowVisible% Lib "user" Alias "IsWindowVisible" (ByVal hwnd As Integer)
  108. Private Declare Sub apiInvalidateRect Lib "user" Alias "InvalidateRect" (ByVal hwnd As Integer, lpRect As RECT, ByVal bErase As Integer)
  109. Private Declare Sub apiInvalidateRectBynum Lib "user" Alias "InvalidateRect" (ByVal hwnd As Integer, ByVal lpRect As Long, ByVal bErase As Integer)
  110. Private Declare Function apiIsChild% Lib "user" Alias "IsChild" (ByVal hWndParent As Integer, ByVal hwnd As Integer)
  111. Private Declare Function apiIsIconic% Lib "user" Alias "IsIconic" (ByVal hwnd As Integer)
  112. Private Declare Function apiIsZoomed% Lib "user" Alias "IsZoomed" (ByVal hwnd As Integer)
  113. Private Declare Function apiLockWindowUpdate% Lib "user" Alias "LockWindowUpdate" (ByVal hwnd As Integer)
  114. Private Declare Sub apiMoveWindow Lib "user" Alias "MoveWindow" (ByVal hwnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer)
  115. Private Declare Function apiOpenIcon% Lib "user" Alias "OpenIcon" (ByVal hwnd As Integer)
  116. Private Declare Function apiRedrawWindow% Lib "user" Alias "RedrawWindow" (ByVal hwnd As Integer, lprcUpdate As RECT, ByVal hRgnUpdate As Integer, ByVal fuRedraw As Integer)
  117. Private Declare Sub apiReleaseCapture Lib "user" Alias "ReleaseCapture" ()
  118. Private Declare Sub apiScreenToClient Lib "user" (ByVal hwnd As Integer, lpPoint As POINTAPI)
  119. Private Declare Sub apiScrollWindow Lib "user" Alias "ScrollWindow" (ByVal hwnd As Integer, ByVal XAmount As Integer, ByVal YAmount As Integer, lpRect As RECT, lpClipRect As RECT)
  120. Private Declare Sub apiScrollWindowByval Lib "user" Alias "ScrollWindow" (ByVal hwnd As Long, ByVal XAmount As Integer, ByVal YAmount As Integer, ByVal lpRect As Long, ByVal lpClipRect As Long)
  121. Private Declare Sub apiScrollWindowEx Lib "user" Alias "ScrollWindowEx" (ByVal hwnd As Integer, ByVal dx As Integer, ByVal dy As Integer, lprcScroll As RECT, lprcClip As RECT, ByVal hRgnUpdate As Integer, lprcUpdate As RECT, ByVal fuScroll As Integer)
  122. Private Declare Function apiSetActiveWindow% Lib "user" Alias "SetActiveWindow" (ByVal hwnd As Integer)
  123. Private Declare Function apiSetCapture% Lib "user" Alias "SetCapture" (ByVal hwnd As Integer)
  124. Private Declare Function apiSetFocus% Lib "user" Alias "SetFocus" (ByVal hwnd As Integer)
  125. 'Function SetForegroundWindow is not available in the WIN16 API.
  126. Private Declare Function apiSetParent% Lib "user" Alias "SetParent" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer)
  127. Private Declare Sub apiSetWindowPos Lib "user" Alias "SetWindowPos " (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
  128. Private Declare Sub apiSetWindowText Lib "user" Alias "SetWindowText" (ByVal hwnd As Integer, ByVal lpString As String)
  129. ' are those indexes supposed to be long?
  130. Private Declare Function apiSetWindowLong% Lib "user" Alias "SetWindowLong" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
  131. Private Declare Function apiSetWindowWord% Lib "user" Alias "SetWindowWord" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Integer)
  132. Private Declare Sub apiShowOwnedPopups Lib "user" Alias "ShowOwnedPopups" (ByVal hwnd As Integer, ByVal fshow As Integer)
  133. Private Declare Function apiShowWindow% Lib "user" Alias "ShowWindow" (ByVal hwnd As Integer, ByVal nCmdShow As Integer)
  134. 'Function ShowWindowAsync is not available in the WIN16 API.
  135. Private Declare Sub apiValidateRect Lib "user" (ByVal hwnd As Integer, lpRect As RECT)
  136. Private Declare Sub apiValidateRectBynum Lib "user" Alias "ValidateRect" (ByVal hwnd As Integer, ByVal lpRect As Long)
  137. Private Declare Function apiArrangeIconicWindows% Lib "user" Alias "ArrangeIconicWindows" (ByVal hwnd As Integer)
  138. Private Declare Sub apiBringWindowToTop Lib "user" Alias "BringWindowToTop " (ByVal hwnd As Integer)
  139. Private Declare Function apiChildWindowFromPoint% Lib "user" Alias "ChildWindowFromPoint" (ByVal hwnd As Integer, ByVal pnt As Any)
  140. 'Function ChildWindowFromPointEx is not available in the WIN16 API.
  141. Private Declare Function apiGetClassName% Lib "user" Alias "GetClassName" (ByVal hwnd As Integer, ByVal lpClassName As String, ByVal nMaxCount As Integer)
  142. Private Declare Function apiFlashWindow% Lib "user" Alias "FlashWindow" (ByVal hwnd As Integer, ByVal bInvert As Integer)
  143. Private Declare Function apiEnableWindow% Lib "user" Alias "EnableWindow" (ByVal hwnd As Integer, ByVal aBOOL As Integer)
  144. Private Declare Sub apiCloseWindow Lib "user" Alias "CloseWindow" (ByVal hwnd As Integer)
  145. Private Declare Function apiDestroyWindow% Lib "user" Alias "DestroyWindow" (ByVal hwnd As Integer)
  146. Private Declare Sub apiClientToScreen Lib "user" Alias "ClientToScreen" (ByVal hwnd As Integer, lpPoint As POINTAPI)
  147. Private Declare Function apiWindowFromPoint% Lib "user" Alias "WindowFromPoint" (ByVal pnt As Any)
  148.  
  149. Private Declare Function apiGetClientRect% Lib "user" Alias "GetClientRect" (ByVal hwnd As Integer, lpRect As RECT)
  150. Private Declare Function apiGetWindowText% Lib "user" Alias "GetWindowText" (ByVal hwnd As Integer, ByVal lpString As String, ByVal aint As Integer)
  151. Private Declare Function apiGetWindowTextLength% Lib "user" Alias "GetWindowTextLength" (ByVal hwnd As Integer)
  152. Private Declare Function apiIsWindow% Lib "user" Alias "IsWindow" (ByVal hwnd As Integer)
  153. Private Declare Sub apiUpdateWindow Lib "user" Alias "UpdateWindow" (ByVal hwnd As Integer)
  154. Private Declare Function apiGetClassLong& Lib "user" Alias "GetClassLong" (ByVal hwnd As Integer, ByVal nIndex As Integer)
  155.  
  156. Private Declare Function apiInvalidateRgn% Lib "user" Alias "InvalidateRgn" (ByVal hwnd As Integer, ByVal hRgn As Integer, ByVal bErase As Integer)
  157. Private Declare Function apiSendMessage& Lib "user" Alias "SendMessage" (ByVal hwnd As Integer, ByVal nMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long)
  158. Private Declare Sub apiDragAcceptFiles Lib "shell.dll" Alias "DragAcceptFiles" (ByVal hwnd As Integer, ByVal accept As Boolean)
  159. #End If 'WIN16
  160.  
  161. Private Sub RaiseWinError(Optional errval)
  162.     If IsMissing(errval) Then
  163.         RaiseError DWERR_APIRESULT, "dwWindow"
  164.     Else
  165.         RaiseError errval, "dwWindow"
  166.     End If
  167. End Sub
  168.  
  169. Public Property Get hwnd() As Long
  170.     hwnd = iHwnd
  171. End Property
  172.  
  173. Public Property Let hwnd(vNewValue As Long)
  174.     Dim tmpDwRect As New dwRECT
  175.     
  176.     If vNewValue = 0 Then
  177.         iHwnd = vNewValue
  178.         Exit Property
  179.     End If
  180.     
  181.     If apiIsWindow(vNewValue) = 0 Then
  182.         RaiseWinError 380
  183.         Exit Property
  184.     End If
  185.     iHwnd = vNewValue
  186.     
  187.     Set tmpDwRect = GetWindowRect()
  188.     iLeft = tmpDwRect.left
  189.     iTop = tmpDwRect.top
  190.     iWidth = tmpDwRect.right - tmpDwRect.left
  191.     iHeight = tmpDwRect.bottom - tmpDwRect.top
  192.     Set tmpDwRect = Nothing
  193. End Property
  194.  
  195. Public Sub BringWindowToTop()
  196. Attribute BringWindowToTop.VB_HelpID = 2804
  197. Attribute BringWindowToTop.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  198.     Dim ret&
  199.     
  200.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  201. #If Win32 Then
  202.     ret& = apiBringWindowToTop(iHwnd)
  203.     If ret& = 0 Then RaiseWinError
  204. #Else
  205.     apiBringWindowToTop iHwnd
  206. #End If
  207. End Sub
  208.  
  209. Public Function GetWindowTextLength() As Long
  210. Attribute GetWindowTextLength.VB_HelpID = 2953
  211. Attribute GetWindowTextLength.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  212.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  213.     GetWindowTextLength = apiGetWindowTextLength(iHwnd)
  214. End Function
  215.  
  216. Public Function GetWindowText() As String
  217. Attribute GetWindowText.VB_HelpID = 2952
  218. Attribute GetWindowText.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  219.     Dim l&
  220.     Dim r$
  221.     Dim ret&
  222.     
  223.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  224.     l = apiGetWindowTextLength(iHwnd)
  225.     r$ = String$(l + 1, 0)
  226.     ret& = apiGetWindowText(iHwnd, r$, l + 1)
  227.     If ret& = 0 Then RaiseWinError
  228.     GetWindowText = left$(r$, l)
  229. End Function
  230.  
  231. Public Function GetClientRect() As dwRECT
  232. Attribute GetClientRect.VB_HelpID = 2954
  233. Attribute GetClientRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  234.     Dim rc As RECT
  235.     Dim newRect As New dwRECT
  236.     Dim ret&
  237.     
  238.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  239.     ret& = apiGetClientRect(iHwnd, rc)
  240.     #If Win32 Then
  241.         If ret& = 0 Then RaiseWinError
  242.     #End If
  243.     Call newRect.SetRect(rc.left, rc.top, rc.right, rc.bottom)
  244.     Set GetClientRect = newRect
  245. End Function
  246.  
  247. #If FlagGetDC = True Then
  248. Public Function GetDC() As dwDeviceContext
  249. Attribute GetDC.VB_HelpID = 2922
  250. Attribute GetDC.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  251.     Dim h As New dwDeviceContext
  252.     
  253.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  254.     h.GetDC Me
  255.     Set GetDC = h
  256. End Function
  257. #End If 'FlagGetDC
  258.  
  259. Public Function IsWindowEnabled() As Boolean
  260. Attribute IsWindowEnabled.VB_HelpID = 2878
  261. Attribute IsWindowEnabled.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  262.     If apiIsWindowEnabled(iHwnd) = 0 Then
  263.         IsWindowEnabled = False
  264.     Else
  265.         IsWindowEnabled = True
  266.     End If
  267. End Function
  268.  
  269. Public Function GetParent() As dwWindow
  270. Attribute GetParent.VB_HelpID = 3008
  271. Attribute GetParent.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  272.     Dim ret&
  273.     Dim newWindow As New dwWindow
  274.     
  275.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  276.     ret& = apiGetParent(iHwnd)
  277.     If ret& = 0 Then
  278.         Set GetParent = newWindow
  279.         Debug.Print "Window Has No Parent"
  280.     Else
  281.         newWindow.hwnd = ret&
  282.         Set GetParent = newWindow
  283.     End If
  284. End Function
  285.  
  286. Public Function GetTopWindow() As dwWindow
  287. Attribute GetTopWindow.VB_HelpID = 3012
  288. Attribute GetTopWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  289.     Dim ret&
  290.     Dim newWindow As New dwWindow
  291.     
  292.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  293.     ret& = apiGetTopWindow(iHwnd)
  294.     newWindow.hwnd = ret&
  295.     Set GetTopWindow = newWindow
  296. End Function
  297.  
  298. Public Function GetWindow(ByVal wCmd) As dwWindow
  299. Attribute GetWindow.VB_HelpID = 3019
  300. Attribute GetWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  301.     Dim ret&
  302.     Dim newWindow As New dwWindow
  303.     
  304.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  305.     ret& = apiGetWindow(iHwnd, wCmd)
  306.     newWindow.hwnd = ret&
  307.     Set GetWindow = newWindow
  308. End Function
  309.  
  310. Public Function GetWindowLong(ByVal nIndex) As Long
  311. Attribute GetWindowLong.VB_HelpID = 3001
  312. Attribute GetWindowLong.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  313.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  314.     GetWindowLong = apiGetWindowLong(iHwnd, nIndex)
  315. End Function
  316.  
  317. Public Function GetWindowRect() As dwRECT
  318. Attribute GetWindowRect.VB_HelpID = 2955
  319. Attribute GetWindowRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  320.     Dim rc As RECT
  321.     Dim newRect As New dwRECT
  322.     Dim ret&
  323.     
  324.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  325. #If Win32 Then
  326.     ret& = apiGetWindowRect(iHwnd, rc)
  327.     If ret& = 0 Then RaiseWinError
  328. #Else
  329.     apiGetWindowRect iHwnd, rc
  330. #End If
  331.     Call newRect.SetRect(rc.left, rc.top, rc.right, rc.bottom)
  332.     Set GetWindowRect = newRect
  333. End Function
  334.  
  335. Public Function IsWindowUnicode() As Boolean
  336. Attribute IsWindowUnicode.VB_HelpID = 2876
  337. Attribute IsWindowUnicode.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  338. #If Win32 Then
  339.     If apiIsWindowUnicode(iHwnd) = 0 Then
  340.         IsWindowUnicode = False
  341.     Else
  342.         IsWindowUnicode = True
  343.     End If
  344. #Else
  345.     RaiseWinError DWERR_NOTINWIN16
  346. #End If
  347. End Function
  348.  
  349. Public Function IsWindow() As Boolean
  350. Attribute IsWindow.VB_HelpID = 2785
  351. Attribute IsWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  352.     If apiIsWindow(iHwnd) = 0 Then
  353.         IsWindow = False
  354.     Else
  355.         IsWindow = True
  356.     End If
  357. End Function
  358.  
  359. Public Function IsWindowVisible() As Boolean
  360. Attribute IsWindowVisible.VB_HelpID = 2801
  361. Attribute IsWindowVisible.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  362.     If apiIsWindowVisible(iHwnd) = 0 Then
  363.         IsWindowVisible = False
  364.     Else
  365.         IsWindowVisible = True
  366.     End If
  367. End Function
  368.  
  369. Public Sub InvalidateRect(lpdwRect As dwRECT, bErase As Boolean)
  370. Attribute InvalidateRect.VB_HelpID = 2931
  371. Attribute InvalidateRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  372.     Dim ret&
  373.     
  374.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  375. #If Win32 Then
  376.     ret& = apiInvalidateRectBynum(iHwnd, lpdwRect.GetAddress(), CLng(bErase))
  377.     If ret& = 0 Then RaiseWinError
  378. #Else
  379.     apiInvalidateRectBynum iHwnd, lpdwRect.GetAddress(), CInt(bErase)
  380. #End If
  381. End Sub
  382.  
  383. #If FlagRegion Then
  384. Public Sub InvalidateRgn(rRegion As dwRegion, bErase As Boolean)
  385. Attribute InvalidateRgn.VB_HelpID = 2935
  386. Attribute InvalidateRgn.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  387.     Dim ret&
  388.     
  389.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  390. #If Win32 Then
  391.     ret& = apiInvalidateRgn(iHwnd, rRegion.hRegion, CLng(bErase))
  392. #Else
  393.     ret& = apiInvalidateRgn(iHwnd, rRegion.hRegion, CInt(bErase))
  394. #End If
  395.     If ret& = 0 Then RaiseWinError
  396. End Sub
  397. #End If ' FlagRegion
  398.  
  399. Public Function IsChild(hWndOther As dwWindow) As Boolean
  400. Attribute IsChild.VB_HelpID = 2787
  401. Attribute IsChild.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  402.     If apiIsChild(iHwnd, hWndOther.hwnd) = 0 Then
  403.         IsChild = False
  404.     Else
  405.         IsChild = True
  406.     End If
  407. End Function
  408.  
  409. Public Function IsIconic() As Boolean
  410. Attribute IsIconic.VB_HelpID = 2802
  411. Attribute IsIconic.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  412.     If apiIsIconic(iHwnd) = 0 Then
  413.         IsIconic = False
  414.     Else
  415.         IsIconic = True
  416.     End If
  417. End Function
  418.  
  419. Public Function IsZoomed() As Boolean
  420. Attribute IsZoomed.VB_HelpID = 2805
  421. Attribute IsZoomed.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  422.     If apiIsZoomed(iHwnd) = 0 Then
  423.         IsZoomed = False
  424.     Else
  425.         IsZoomed = True
  426.     End If
  427. End Function
  428.  
  429. Public Sub LockWindowUpdate(Locking As Boolean)
  430. Attribute LockWindowUpdate.VB_HelpID = 2938
  431. Attribute LockWindowUpdate.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  432.     Dim ret&
  433.     
  434.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  435.     If Locking = True Then
  436.         ret& = apiLockWindowUpdate(iHwnd)
  437.     Else
  438.         ret& = apiLockWindowUpdate(0)
  439.     End If
  440.     If ret& = 0 Then RaiseWinError
  441. End Sub
  442.  
  443. Public Sub MoveWindow(ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, bRepaint As Boolean)
  444. Attribute MoveWindow.VB_HelpID = 2794
  445. Attribute MoveWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  446.     Dim ret&
  447.     
  448.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  449. #If Win32 Then
  450.     ret& = apiMoveWindow(iHwnd, x, y, nWidth, nHeight, CLng(bRepaint))
  451.     If ret& = 0 Then RaiseWinError
  452. #Else
  453.     apiMoveWindow iHwnd, x, y, nWidth, nHeight, CInt(bRepaint)
  454. #End If
  455. End Sub
  456.  
  457. Public Sub OpenIcon()
  458. Attribute OpenIcon.VB_HelpID = 2792
  459. Attribute OpenIcon.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  460.     Dim ret&
  461.     
  462.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  463.     ret& = apiOpenIcon(iHwnd)
  464.     If ret& = 0 Then RaiseWinError
  465. End Sub
  466.  
  467. #If FlagRedrawWindow Then
  468. Public Sub RedrawWindow(lprcUpdate As dwRECT, hRgnUpdate As dwRegion, ByVal fuRedraw)
  469. Attribute RedrawWindow.VB_HelpID = 2937
  470. Attribute RedrawWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  471.     Dim tempRect As RECT
  472.     Dim ret&
  473.     
  474.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  475.     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect.left)
  476.     ret& = apiRedrawWindow(iHwnd, tempRect, hRgnUpdate.hRegion, fuRedraw)
  477.     If ret& = 0 Then RaiseWinError
  478. End Sub
  479. #End If
  480.  
  481. Public Sub ReleaseCapture()
  482. Attribute ReleaseCapture.VB_HelpID = 2873
  483. Attribute ReleaseCapture.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  484.     Dim ret&
  485.     
  486.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  487. #If Win32 Then
  488.     ret& = apiReleaseCapture()
  489.     If ret& = 0 Then RaiseWinError
  490. #Else
  491.     apiReleaseCapture
  492. #End If
  493. End Sub
  494.  
  495. Public Sub UpdateWindow()
  496. Attribute UpdateWindow.VB_HelpID = 2917
  497. Attribute UpdateWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  498.     Dim ret&
  499.     
  500.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  501. #If Win32 Then
  502.     ret& = apiUpdateWindow(iHwnd)
  503.     If ret& = 0 Then RaiseWinError
  504. #Else
  505.     apiUpdateWindow iHwnd
  506. #End If
  507. End Sub
  508.  
  509. Public Sub ScreenToClient(ByVal pPoint As dwPoint)
  510. Attribute ScreenToClient.VB_HelpID = 2978
  511. Attribute ScreenToClient.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  512.     Dim tempPoint As POINTAPI
  513.     Dim ret&
  514.     
  515.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  516.     tempPoint.x = pPoint.x
  517.     tempPoint.y = pPoint.y
  518. #If Win32 Then
  519.     ret& = apiScreenToClient(iHwnd, tempPoint)
  520.     If ret& = 0 Then RaiseWinError
  521. #Else
  522.     apiScreenToClient iHwnd, tempPoint
  523. #End If
  524.     pPoint.x = tempPoint.x
  525.     pPoint.y = tempPoint.y
  526. End Sub
  527.  
  528. Public Sub ClientToScreen(pPoint As dwPoint)
  529. Attribute ClientToScreen.VB_HelpID = 2977
  530. Attribute ClientToScreen.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  531.     Dim tempPoint As POINTAPI
  532.     Dim ret&
  533.     
  534.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  535.     tempPoint.x = pPoint.x
  536.     tempPoint.y = pPoint.y
  537. #If Win32 Then
  538.     ret& = apiClientToScreen(iHwnd, tempPoint)
  539.     If ret& = 0 Then RaiseWinError
  540. #Else
  541.     apiClientToScreen iHwnd, tempPoint
  542. #End If
  543.     pPoint.x = tempPoint.x
  544.     pPoint.y = tempPoint.y
  545. End Sub
  546.  
  547. ' lpdwRect is a dwRect, lpClipdwRect is a dwRect
  548. Public Sub ScrollWindow(ByVal XAmount, ByVal YAmount, Optional lpdwRect As Variant, Optional lpClipdwRect As Variant)
  549. Attribute ScrollWindow.VB_HelpID = 2939
  550. Attribute ScrollWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  551.     Dim tempRect1 As RECT
  552.     Dim tempRect2 As RECT
  553.     Dim ret&
  554.  
  555.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  556.     If IsMissing(lpClipdwRect) Then
  557.         If IsMissing(lpdwRect) Then
  558.             #If Win32 Then
  559.                 ret& = apiScrollWindowByval(iHwnd, XAmount, YAmount, 0, 0)
  560.                 If ret& = 0 Then RaiseWinError
  561.             #Else
  562.                 apiScrollWindowByval iHwnd, XAmount, YAmount, 0, 0
  563.             #End If
  564.         Else
  565.             lpdwRect.CopyToRECT agGetAddressForObject(tempRect1.left)
  566.             #If Win32 Then
  567.                 ret& = apiScrollWindowByval(iHwnd, XAmount, YAmount, agGetAddressForObject(tempRect1), 0)
  568.                 If ret& = 0 Then RaiseWinError
  569.             #Else
  570.                 apiScrollWindowByval iHwnd, XAmount, YAmount, agGetAddressForObject(tempRect1), 0
  571.             #End If
  572.         End If
  573.     Else
  574.         If IsMissing(lpdwRect) Then
  575.             lpClipdwRect.CopyToRECT agGetAddressForObject(tempRect2.left)
  576.             #If Win32 Then
  577.                 ret& = apiScrollWindowByval(iHwnd, XAmount, YAmount, 0, agGetAddressForObject(tempRect2))
  578.                 If ret& = 0 Then RaiseWinError
  579.             #Else
  580.                 apiScrollWindowByval iHwnd, XAmount, YAmount, 0, agGetAddressForObject(tempRect2)
  581.             #End If
  582.         Else
  583.             lpdwRect.CopyToRECT agGetAddressForObject(tempRect1.left)
  584.             lpClipdwRect.CopyToRECT agGetAddressForObject(tempRect2.left)
  585.             #If Win32 Then
  586.                 ret& = apiScrollWindowByval(iHwnd, XAmount, YAmount, agGetAddressForObject(tempRect1), agGetAddressForObject(tempRect2))
  587.                 If ret& = 0 Then RaiseWinError
  588.             #Else
  589.                 apiScrollWindowByval iHwnd, XAmount, YAmount, agGetAddressForObject(tempRect1), agGetAddressForObject(tempRect2)
  590.             #End If
  591.         End If
  592.     End If
  593. End Sub
  594.  
  595. ' lprcScroll As dwRECT, lprcClip As dwRECT, hRgnUpdate As dwRegion, lprcUpdate As dwRECT, fuScroll as long
  596. Public Sub ScrollWindowEx(ByVal dx As Long, ByVal dy As Long, Optional lprcScroll As Variant, Optional lprcClip As Variant, Optional hRgnUpdate As Variant, Optional lprcUpdate As Variant, Optional fuScroll As Variant)
  597. Attribute ScrollWindowEx.VB_HelpID = 2941
  598. Attribute ScrollWindowEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  599. #If Win32 Then
  600.     Dim ret&
  601.     Dim tempRect1 As RECT
  602.     Dim tempRect2 As RECT
  603.     Dim tempRect3 As RECT
  604.     Dim tempflags As Long
  605.     
  606.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  607.     If IsMissing(fuScroll) Then
  608.         tempflags = 0
  609.     Else
  610.         tempflags = fuScroll
  611.     End If
  612.     
  613.     If IsMissing(lprcScroll) Then
  614.         If IsMissing(lprcClip) Then
  615.             If IsMissing(hRgnUpdate) Then
  616.                 If IsMissing(lprcUpdate) Then
  617.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, 0, 0, 0, tempflags)
  618.                 Else
  619.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  620.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, 0, 0, agGetAddressForObject(tempRect1), tempflags)
  621.                 End If
  622.             Else
  623.                 If IsMissing(lprcUpdate) Then
  624.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, 0, hRgnUpdate.hRegion, 0, tempflags)
  625.                 Else
  626.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  627.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, 0, hRgnUpdate.hRegion, agGetAddressForObject(tempRect1), tempflags)
  628.                 End If
  629.             End If
  630.         Else
  631.             If IsMissing(hRgnUpdate) Then
  632.                 If IsMissing(lprcUpdate) Then
  633.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  634.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, agGetAddressForObject(tempRect2), 0, 0, tempflags)
  635.                 Else
  636.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  637.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  638.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, agGetAddressForObject(tempRect2), 0, agGetAddressForObject(tempRect1), tempflags)
  639.                 End If
  640.             Else
  641.                 If IsMissing(lprcUpdate) Then
  642.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  643.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, agGetAddressForObject(tempRect2), hRgnUpdate.hRegion, 0, tempflags)
  644.                 Else
  645.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  646.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  647.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, 0, agGetAddressForObject(tempRect2), hRgnUpdate.hRegion, agGetAddressForObject(tempRect1), tempflags)
  648.                 End If
  649.             End If
  650.         End If
  651.     Else
  652.         If IsMissing(lprcClip) Then
  653.             If IsMissing(hRgnUpdate) Then
  654.                 If IsMissing(lprcUpdate) Then
  655.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  656.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), 0, 0, 0, tempflags)
  657.                 Else
  658.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  659.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  660.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), 0, 0, agGetAddressForObject(tempRect1), tempflags)
  661.                 End If
  662.             Else
  663.                 If IsMissing(lprcUpdate) Then
  664.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  665.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), 0, hRgnUpdate.hRegion, 0, tempflags)
  666.                 Else
  667.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  668.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  669.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), 0, hRgnUpdate.hRegion, agGetAddressForObject(tempRect1), tempflags)
  670.                 End If
  671.             End If
  672.         Else
  673.             If IsMissing(hRgnUpdate) Then
  674.                 If IsMissing(lprcUpdate) Then
  675.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  676.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  677.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), agGetAddressForObject(tempRect2), 0, 0, tempflags)
  678.                 Else
  679.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  680.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  681.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  682.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), agGetAddressForObject(tempRect2), 0, agGetAddressForObject(tempRect1), tempflags)
  683.                 End If
  684.             Else
  685.                 If IsMissing(lprcUpdate) Then
  686.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  687.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  688.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), agGetAddressForObject(tempRect2), hRgnUpdate.hRegion, 0, tempflags)
  689.                 Else
  690.                     lprcUpdate.CopyToRECT agGetAddressForObject(tempRect1.left)
  691.                     lprcClip.CopyToRECT agGetAddressForObject(tempRect2.left)
  692.                     lprcScroll.CopyToRECT agGetAddressForObject(tempRect3.left)
  693.                     ret& = apiScrollWindowExByval(iHwnd, dx, dy, agGetAddressForObject(tempRect3), agGetAddressForObject(tempRect2), hRgnUpdate.hRegion, agGetAddressForObject(tempRect1), tempflags)
  694.                 End If
  695.             End If
  696.         End If
  697.     End If
  698.  
  699.     If ret& = 0 Then RaiseWinError
  700. #Else
  701.     RaiseWinError DWERR_NOTINWIN16
  702. #End If
  703. End Sub
  704.  
  705. Public Sub SetActiveWindow()
  706. Attribute SetActiveWindow.VB_HelpID = 2918
  707. Attribute SetActiveWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  708.     Dim ret&
  709.     
  710.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  711.     ret& = apiSetActiveWindow(iHwnd)
  712.     If ret& = 0 Then RaiseWinError
  713. End Sub
  714.  
  715. Public Sub SetCapture()
  716. Attribute SetCapture.VB_HelpID = 2872
  717. Attribute SetCapture.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  718.     Dim ret&
  719.     
  720.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  721.     ret& = apiSetCapture(iHwnd)
  722.     If ret& = 0 Then RaiseWinError
  723. End Sub
  724.  
  725. Public Sub SetFocus()
  726. Attribute SetFocus.VB_HelpID = 2852
  727. Attribute SetFocus.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  728.     Dim ret&
  729.     
  730.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  731.     ret& = apiSetFocus(iHwnd)
  732.     If ret& = 0 Then RaiseWinError
  733. End Sub
  734.  
  735. Public Sub SetForegroundWindow()
  736. Attribute SetForegroundWindow.VB_HelpID = 2920
  737. Attribute SetForegroundWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  738. #If Win32 Then
  739.     Dim ret&
  740.     
  741.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  742.     ret& = apiSetForegroundWindow(iHwnd)
  743.     If ret& = 0 Then RaiseWinError
  744. #Else
  745.     RaiseWinError DWERR_NOTINWIN16
  746. #End If
  747. End Sub
  748.  
  749. Public Sub SetParent(hWndNewParent As dwWindow)
  750. Attribute SetParent.VB_HelpID = 3009
  751. Attribute SetParent.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  752.     Dim ret&
  753.     
  754.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  755.     ret& = apiSetParent(iHwnd, hWndNewParent.hwnd)
  756.     If ret& = 0 Then RaiseWinError
  757. End Sub
  758.  
  759. Public Sub SetWindowPos(hWndInsertAfter As dwWindow, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags)
  760. Attribute SetWindowPos.VB_HelpID = 2795
  761. Attribute SetWindowPos.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  762.     Dim ret&
  763.     
  764.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  765. #If Win32 Then
  766.     ret& = apiSetWindowPos(iHwnd, hWndInsertAfter.hwnd, x, y, cx, cy, wFlags)
  767.     If ret& = 0 Then RaiseWinError
  768. #Else
  769.     apiSetWindowPos iHwnd, hWndInsertAfter.hwnd, x, y, cx, cy, wFlags
  770. #End If
  771. End Sub
  772.  
  773. Public Sub SetWindowText(lpString As String)
  774. Attribute SetWindowText.VB_HelpID = 2951
  775. Attribute SetWindowText.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  776.     Dim ret&
  777.     
  778.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  779. #If Win32 Then
  780.     ret& = apiSetWindowText(iHwnd, lpString)
  781.     If ret& = 0 Then RaiseWinError
  782. #Else
  783.     apiSetWindowText iHwnd, lpString
  784. #End If
  785. End Sub
  786.  
  787. Public Sub SetWindowWord(ByVal nIndex, dwNewWord As Integer)
  788. Attribute SetWindowWord.VB_HelpID = 3000
  789. Attribute SetWindowWord.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  790.     Dim ret&
  791.     
  792.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  793.     ret& = apiSetWindowWord(iHwnd, nIndex, dwNewWord)
  794.     If ret& = 0 Then RaiseWinError
  795. End Sub
  796.  
  797. Public Sub ShowOwnedPopups(fshow As Boolean)
  798. Attribute ShowOwnedPopups.VB_HelpID = 2791
  799. Attribute ShowOwnedPopups.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  800.     Dim ret&
  801.     
  802.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  803. #If Win32 Then
  804.     ret& = apiShowOwnedPopups(iHwnd, CLng(fshow))
  805.     If ret& = 0 Then RaiseWinError
  806. #Else
  807.     apiShowOwnedPopups iHwnd, CInt(fshow)
  808. #End If
  809. End Sub
  810.  
  811. Public Sub ShowWindow(ByVal nCmdShow As Long)
  812. Attribute ShowWindow.VB_HelpID = 2789
  813. Attribute ShowWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  814.     Dim ret&
  815.     
  816.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  817.     ret& = apiShowWindow(iHwnd, nCmdShow)
  818.     If ret& = 0 Then RaiseWinError
  819. End Sub
  820.  
  821. Public Sub ShowWindowAsync(ByVal nCmdShow As Long) ' causes error
  822. Attribute ShowWindowAsync.VB_HelpID = 3444
  823. Attribute ShowWindowAsync.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  824. #If Win32 Then
  825.     Dim ret&
  826.     
  827.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  828.     ret& = apiShowWindowAsync(iHwnd, nCmdShow)
  829.     If ret& = 0 Then RaiseWinError
  830. #Else
  831.     RaiseWinError DWERR_NOTINWIN16
  832. #End If
  833. End Sub
  834.  
  835. Public Sub ValidateRect(lpdwRect As dwRECT)
  836. Attribute ValidateRect.VB_HelpID = 2933
  837. Attribute ValidateRect.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  838.     Dim ret&
  839.     
  840.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  841. #If Win32 Then
  842.     ret& = apiValidateRectBynum(iHwnd, lpdwRect.GetAddress())
  843.     If ret& = 0 Then RaiseWinError
  844. #Else
  845.     apiValidateRectBynum iHwnd, lpdwRect.GetAddress()
  846. #End If
  847. End Sub
  848.  
  849. ' This is a replacement for somehow passing 0 to
  850. ' ValidateRect.
  851. Public Sub ValidateWindow()
  852. Attribute ValidateWindow.VB_HelpID = 2934
  853. Attribute ValidateWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  854.     Dim ret&
  855.     
  856.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  857. #If Win32 Then
  858.     ret& = apiValidateRectBynum(iHwnd, 0)
  859.     If ret& = 0 Then RaiseWinError
  860. #Else
  861.     apiValidateRectBynum iHwnd, 0
  862. #End If
  863. End Sub
  864.  
  865. Public Sub ArrangeIconicWindows()
  866. Attribute ArrangeIconicWindows.VB_HelpID = 2049
  867. Attribute ArrangeIconicWindows.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  868.     Dim ret&
  869.     
  870.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  871.     
  872.     ret& = apiArrangeIconicWindows(iHwnd)
  873.     If ret& = 0 Then RaiseWinError
  874. End Sub
  875.  
  876. Public Function WindowFromPoint(pPoint As dwPoint) As dwWindow
  877. Attribute WindowFromPoint.VB_HelpID = 2980
  878. Attribute WindowFromPoint.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  879. #If Win32 Then
  880.     Dim ret As Long
  881. #Else
  882.     Dim ret As Integer
  883.     Dim lPnt As Long
  884. #End If
  885.     Dim newWindow As New dwWindow
  886.     
  887.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  888. #If Win32 Then
  889.     ret = apiWindowFromPoint(pPoint.x, pPoint.y)
  890. #Else
  891.     lPnt = (pPoint.x * 65536) + pPoint.y ' convert point coordinates into a long integer
  892.     ret = apiWindowFromPoint(lPnt)
  893. #End If
  894.     If ret = 0 Then RaiseWinError
  895.     newWindow.hwnd = ret
  896.     Set WindowFromPoint = newWindow
  897. End Function
  898.  
  899. Public Function ChildWindowFromPoint(pPoint As dwPoint) As dwWindow
  900. Attribute ChildWindowFromPoint.VB_HelpID = 2981
  901. Attribute ChildWindowFromPoint.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  902. #If Win32 Then
  903.     Dim ret As Long
  904. #Else
  905.     Dim ret As Integer
  906.     Dim lPnt As Long
  907. #End If
  908.     Dim newWindow As New dwWindow
  909.     
  910.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  911. #If Win32 Then
  912.     ret = apiChildWindowFromPoint(iHwnd, pPoint.x, pPoint.y)
  913. #Else
  914.     lPnt = (pPoint.x * 65536) + pPoint.y ' convert point coordinates into a long integer
  915.     ret = apiChildWindowFromPoint(iHwnd, lPnt)
  916. #End If
  917.     If ret = 0 Then RaiseWinError
  918.     newWindow.hwnd = ret
  919.     Set ChildWindowFromPoint = newWindow
  920. End Function
  921.  
  922. Public Function ChildWindowFromPointEx(pPoint As dwPoint, uFlags As Long) As dwWindow
  923. Attribute ChildWindowFromPointEx.VB_HelpID = 3434
  924. Attribute ChildWindowFromPointEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  925. #If Win32 Then
  926.     Dim ret&
  927.     Dim newWindow As New dwWindow
  928.     
  929.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  930.     ret& = apiChildWindowFromPointEx(iHwnd, pPoint.x, pPoint.y, uFlags)
  931.     If ret& = 0 Then RaiseWinError
  932.     newWindow.hwnd = ret&
  933.     Set ChildWindowFromPointEx = newWindow
  934. #Else
  935.     RaiseWinError DWERR_NOTINWIN16
  936. #End If
  937. End Function
  938.  
  939. Public Function GetClassName() As String
  940. Attribute GetClassName.VB_HelpID = 3011
  941. Attribute GetClassName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  942.     Dim clsName$
  943.     Dim length&
  944.     
  945.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  946.     clsName$ = String$(MAX_LEN, 0)
  947.     length& = Len(clsName$)
  948.     length& = apiGetClassName(iHwnd, clsName$, length& + 1)
  949.     GetClassName = left$(clsName$, length&)
  950. End Function
  951.  
  952. Public Function GetClassLong(ByVal nIndex As Long) As Long
  953. Attribute GetClassLong.VB_HelpID = 2005
  954. Attribute GetClassLong.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  955.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  956.     GetClassLong = apiGetClassLong(iHwnd, nIndex)
  957. End Function
  958.  
  959. Public Function FlashWindow(bInvert As Boolean) As Boolean
  960. Attribute FlashWindow.VB_HelpID = 2790
  961. Attribute FlashWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  962.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  963. #If Win32 Then
  964.     FlashWindow = apiFlashWindow(iHwnd, CLng(bInvert))
  965. #Else
  966.     FlashWindow = apiFlashWindow(iHwnd, CInt(bInvert))
  967. #End If
  968. End Function
  969.  
  970. ' dwWindow, string, string
  971. Public Function FindWindowEx(Optional hWndChildAfter As Variant, Optional lpClassName As Variant, Optional lpWindowName As Variant) As dwWindow
  972. Attribute FindWindowEx.VB_HelpID = 3440
  973. Attribute FindWindowEx.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  974. #If Win32 Then
  975.     Dim ret&
  976.     Dim newWindow As New dwWindow
  977.  
  978.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  979.     ret& = apiFindWindowEx(iHwnd, hWndChildAfter.hwnd, CStr(lpClassName), CStr(lpWindowName))
  980.     newWindow.hwnd = ret&
  981.     Set FindWindowEx = newWindow
  982. #Else
  983.     RaiseWinError DWERR_NOTINWIN16
  984. #End If
  985. End Function
  986.  
  987. Public Sub EnableWindow(ByVal fEnable As Boolean)
  988. Attribute EnableWindow.VB_HelpID = 2877
  989. Attribute EnableWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  990.     Dim ret&
  991.     
  992.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  993.     ret& = apiEnableWindow(iHwnd, CLng(fEnable))
  994.     'Checking ret& is not needed since EnableWindow can return either true OR false on success.
  995. End Sub
  996.  
  997. Public Sub CloseWindow()
  998. Attribute CloseWindow.VB_HelpID = 2793
  999. Attribute CloseWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1000.     Dim ret&
  1001.     
  1002.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1003. #If Win32 Then
  1004.     ret& = apiCloseWindow(iHwnd)
  1005. #Else
  1006.     apiCloseWindow iHwnd
  1007. #End If
  1008.     If ret& = 0 Then RaiseWinError
  1009. End Sub
  1010.  
  1011. Public Sub DestroyWindow()
  1012. Attribute DestroyWindow.VB_HelpID = 2788
  1013. Attribute DestroyWindow.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1014.     Dim ret As Boolean
  1015.     
  1016.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1017.     ret = apiDestroyWindow(iHwnd)
  1018.     If ret = False Then RaiseWinError
  1019. End Sub
  1020.  
  1021.  
  1022. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  1023. ' The following is for compatibility with the
  1024. ' API Foundation Library Standard.  It is not a full
  1025. ' implementation, as this library was completed before
  1026. ' the final version of the standard was completed.
  1027. ' There are also a number of functions that are not
  1028. ' completed for lack of time or because adequate
  1029. ' documentation was not provided.  The API foundation standard
  1030. ' may change at any time after this libray is released,
  1031. ' so the functions below may not be correct.
  1032.  
  1033. ' The "Attach" functions are ways of setting up the
  1034. ' class.  Most of the functions below are the same
  1035. ' as the API functions above, but are renamed for
  1036. ' some reason.
  1037.  
  1038.  
  1039. Public Sub Attach(newHwnd As Long)
  1040.     Dim tmpDwRect As New dwRECT
  1041.     
  1042.     If newHwnd = 0 Then
  1043.         iHwnd = newHwnd
  1044.         Exit Sub
  1045.     End If
  1046.     
  1047.     If apiIsWindow(newHwnd) = 0 Then
  1048.         RaiseWinError 380
  1049.         Exit Sub
  1050.     End If
  1051.     iHwnd = newHwnd
  1052.     
  1053.     Set tmpDwRect = GetWindowRect()
  1054.     iLeft = tmpDwRect.left
  1055.     iTop = tmpDwRect.top
  1056.     iWidth = tmpDwRect.right - tmpDwRect.left
  1057.     iHeight = tmpDwRect.bottom - tmpDwRect.top
  1058.     Set tmpDwRect = Nothing
  1059. End Sub
  1060.  
  1061. Public Sub AttachDesktop()
  1062.     Dim tmpDwRect As New dwRECT
  1063.     
  1064.     iHwnd = apiGetDesktopWindow()
  1065.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1066.     
  1067.     Set tmpDwRect = GetWindowRect()
  1068.     iLeft = tmpDwRect.left
  1069.     iTop = tmpDwRect.top
  1070.     iWidth = tmpDwRect.right - tmpDwRect.left
  1071.     iHeight = tmpDwRect.bottom - tmpDwRect.top
  1072.     Set tmpDwRect = Nothing
  1073. End Sub
  1074.  
  1075. Public Sub AttachForeground()
  1076.     Dim tmpDwRect As New dwRECT
  1077.  
  1078. #If Win32 Then
  1079.     iHwnd = apiGetForegroundWindow()
  1080. #Else
  1081.     iHwnd = apiGetTopWindow(iHwnd)
  1082. #End If
  1083.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1084.     
  1085.     Set tmpDwRect = GetWindowRect()
  1086.     iLeft = tmpDwRect.left
  1087.     iTop = tmpDwRect.top
  1088.     iWidth = tmpDwRect.right - tmpDwRect.left
  1089.     iHeight = tmpDwRect.bottom - tmpDwRect.top
  1090.     Set tmpDwRect = Nothing
  1091. End Sub
  1092.  
  1093. Public Sub AttachFromPoint(pPoint As dwPoint)
  1094.     Dim tmpDwRect As New dwRECT
  1095.     Dim lPnt As Long
  1096.     
  1097. #If Win32 Then
  1098.     iHwnd = apiChildWindowFromPoint(iHwnd, pPoint.x, pPoint.y)
  1099. #Else
  1100.     lPnt = (pPoint.x * 65536) + pPoint.y ' convert point coordinates into a long integer
  1101.     iHwnd = apiChildWindowFromPoint(iHwnd, lPnt)
  1102. #End If
  1103.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1104.     
  1105.     Set tmpDwRect = GetWindowRect()
  1106.     iLeft = tmpDwRect.left
  1107.     iTop = tmpDwRect.top
  1108.     iWidth = tmpDwRect.right - tmpDwRect.left
  1109.     iHeight = tmpDwRect.bottom - tmpDwRect.top
  1110.     Set tmpDwRect = Nothing
  1111. End Sub
  1112.  
  1113. Public Sub Detach()
  1114.     iHwnd = 0
  1115. End Sub
  1116.  
  1117. Public Sub BringToTop()
  1118. Attribute BringToTop.VB_HelpID = 2804
  1119. Attribute BringToTop.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1120.     BringWindowToTop
  1121. End Sub
  1122.  
  1123. Public Function ChildFromPoint(pPoint As dwPoint) As dwWindow
  1124.     Set ChildFromPoint = ChildWindowFromPoint(pPoint)
  1125. End Function
  1126.  
  1127. Public Function ClassName() As String
  1128. Attribute ClassName.VB_HelpID = 3011
  1129. Attribute ClassName.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1130.     ClassName = GetClassName()
  1131. End Function
  1132.  
  1133. Public Function ClientRectangle() As dwRECT
  1134. Attribute ClientRectangle.VB_HelpID = 2954
  1135. Attribute ClientRectangle.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1136.     Set ClientRectangle = GetClientRect()
  1137. End Function
  1138.  
  1139. Public Sub Destroy()
  1140.     DestroyWindow
  1141.     ' clear any memory used in this class here
  1142. End Sub
  1143.  
  1144. Public Sub DragAcceptFiles(accept As Boolean)
  1145.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1146.     apiDragAcceptFiles iHwnd, accept
  1147. End Sub
  1148.  
  1149. Public Sub Flash(invert As Boolean)
  1150.     FlashWindow invert
  1151. End Sub
  1152.  
  1153. Public Sub Invalidate()
  1154.     InvalidateRect GetWindowRect(), True
  1155. End Sub
  1156.  
  1157. Public Sub InvalidateRectangle(rRect As dwRECT, bErase As Boolean)
  1158.     InvalidateRect rRect, bErase
  1159. End Sub
  1160.  
  1161. #If FlagRegion Then
  1162. Public Sub InvalidateRegion(rRegion As dwRegion, bErase As Boolean)
  1163.     InvalidateRgn rRegion, bErase
  1164. End Sub
  1165. #End If ' FlagRegion
  1166.  
  1167. Public Sub Move(left As Single, Optional top As Variant, Optional Width As Variant, Optional Height As Variant)
  1168. Attribute Move.VB_HelpID = 2794
  1169. Attribute Move.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1170.     Dim tmpTop As Long
  1171.     Dim tmpWidth As Long
  1172.     Dim tmpHeight As Long
  1173.     
  1174.     If IsMissing(top) Then
  1175.         tmpTop = iTop
  1176.     Else
  1177.         tmpTop = top
  1178.     End If
  1179.     
  1180.     If IsMissing(Width) Then
  1181.         tmpWidth = iWidth
  1182.     Else
  1183.         tmpWidth = Width
  1184.     End If
  1185.     
  1186.     If IsMissing(Height) Then
  1187.         tmpHeight = iHeight
  1188.     Else
  1189.         tmpHeight = Height
  1190.     End If
  1191.     MoveWindow left, tmpTop, tmpWidth, tmpHeight, True
  1192. End Sub
  1193.  
  1194. #If FlagRedrawWindow Then
  1195. Public Sub Redraw()
  1196.     Dim tmpRect As New dwRECT
  1197.     Dim tmpRgn As New dwRegion
  1198.     
  1199.     tmpRect = GetWindowRect()
  1200.     RedrawWindow tmpRect, tmpRgn, True
  1201. End Sub
  1202. #End If 'FlagRedrawWindow
  1203.  
  1204. #If FlagRedrawWindow Then
  1205. Public Sub Refresh(Optional ForceInvalidate As Variant)
  1206.     Dim tmpRect As New dwRECT
  1207.     Dim tmpRgn As New dwRegion
  1208.     
  1209.     tmpRect = GetWindowRect()
  1210.     If IsMissing(ForceInvalidate) Then
  1211.         RedrawWindow tmpRect, tmpRgn, True
  1212.     Else
  1213.         RedrawWindow tmpRect, tmpRgn, ForceInvalidate
  1214.     End If
  1215. End Sub
  1216. #End If ' FlagRedrawWindow
  1217.  
  1218. Public Sub Scroll(ByVal XAmount, ByVal YAmount, Optional lpdwRect As Variant, Optional lpClipdwRect As Variant)
  1219.     ScrollWindow XAmount, YAmount, lpdwRect, lpClipdwRect
  1220. End Sub
  1221.  
  1222. #If Win32 Then
  1223. Public Function SendMessage(nMsg As Integer, wParam As Long, lParam As Long) As Long
  1224. Attribute SendMessage.VB_HelpID = 2761
  1225. Attribute SendMessage.VB_Description = "Help available in Visual Basic Programmer's Guide to Win32 API CD ROM"
  1226.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1227.     SendMessage = apiSendMessage(iHwnd, nMsg, wParam, lParam)
  1228. End Function
  1229. #Else ' win16
  1230. Public Function SendMessage(nMsg As Integer, wParam As Integer, lParam As Long) As Long
  1231.     If iHwnd = 0 Then RaiseWinError DWERR_UNINITIALIZED
  1232.     SendMessage = apiSendMessage(iHwnd, nMsg, wParam, lParam)
  1233. End Function
  1234. #End If
  1235.  
  1236. Public Function Show(Optional mode As Variant)
  1237.     ShowWindow mode
  1238. End Function
  1239.  
  1240. Public Function ShowPopups()
  1241.     ShowOwnedPopups True
  1242. End Function
  1243.  
  1244. ' This property is called "pLeft" instead of "Left" because it
  1245. ' causes VB to think that the Left$ function (which is used a
  1246. ' couple of times in this class) is actually a reference to the
  1247. ' property.
  1248. Public Property Get pLeft()
  1249.     pLeft = iLeft
  1250. End Property
  1251.  
  1252. Public Property Let pLeft(vNewValue)
  1253.     iLeft = vNewValue
  1254.     MoveWindow iLeft, iTop, iWidth, iHeight, True
  1255. End Property
  1256.  
  1257. Public Property Get top()
  1258.     top = iTop
  1259. End Property
  1260.  
  1261. Public Property Let top(vNewValue)
  1262.     iTop = vNewValue
  1263.     MoveWindow iLeft, iTop, iWidth, iHeight, True
  1264. End Property
  1265.  
  1266. Public Property Get Width()
  1267.     Width = iWidth
  1268. End Property
  1269.  
  1270. Public Property Let Width(vNewValue)
  1271.     iWidth = vNewValue
  1272.     MoveWindow iLeft, iTop, iWidth, iHeight, True
  1273. End Property
  1274.  
  1275. Public Property Get Height()
  1276.     Height = iHeight
  1277. End Property
  1278.  
  1279. Public Property Let Height(vNewValue)
  1280.     iHeight = vNewValue
  1281.     MoveWindow iLeft, iTop, iWidth, iHeight, True
  1282. End Property
  1283.  
  1284.