home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch05 / ex5.bas < prev    next >
Encoding:
BASIC Source File  |  1997-02-16  |  12.1 KB  |  203 lines

  1. Attribute VB_Name = "CH5_Examples"
  2. ' Copyright ⌐ 1997 by Desaware Inc. All Rights Reserved.
  3.  
  4. Option Explicit
  5. Type RECT
  6.         Left As Long
  7.         Top As Long
  8.         Right As Long
  9.         Bottom As Long
  10. End Type
  11.  
  12. Type SMALLRECT
  13.         Left As Integer
  14.         Top As Integer
  15.         Right As Integer
  16.         Bottom As Integer
  17. End Type
  18.  
  19.  
  20. Type POINTAPI
  21.         x As Long
  22.         y As Long
  23. End Type
  24.  
  25.  
  26. Type SIZE
  27.         cx As Long
  28.         cy As Long
  29. End Type
  30.  
  31. Type WNDCLASS
  32.     style As Long
  33.     lpfnwndproc As Long
  34.     cbClsextra As Long
  35.     cbWndExtra2 As Long
  36.     hInstance As Long
  37.     hIcon As Long
  38.     hCursor As Long
  39.     hbrBackground As Long
  40.     lpszMenuName As Long
  41.     lpszClassName As Long
  42. End Type
  43.  
  44. Type WNDCLASSEX
  45.     cbSize As Long
  46.     style As Long
  47.     lpfnwndproc As Long
  48.     cbClsextra As Long
  49.     cbWndExtra2 As Long
  50.     hInstance As Long
  51.     hIcon As Long
  52.     hCursor As Long
  53.     hbrBackground As Long
  54.     lpszMenuName As Long
  55.     lpszClassName As Long
  56.     hIconSm As Long
  57. End Type
  58.  
  59. Type WINDOWPLACEMENT
  60.         Length As Long
  61.         flags As Long
  62.         showCmd As Long
  63.         ptMinPosition As POINTAPI
  64.         ptMaxPosition As POINTAPI
  65.         rcNormalPosition As RECT
  66. End Type
  67.  
  68. Public Const GWL_WNDPROC = (-4)
  69. Public Const GWL_HINSTANCE = (-6)
  70. Public Const GWL_HWNDPARENT = (-8)
  71. Public Const GWL_STYLE = (-16)
  72. Public Const GWL_EXSTYLE = (-20)
  73. Public Const GWL_USERDATA = (-21)
  74. Public Const GWL_ID = (-12)
  75.  
  76. ' SetWindowPos Flags
  77. Public Const SWP_NOSIZE = &H1
  78. Public Const SWP_NOMOVE = &H2
  79. Public Const SWP_NOZORDER = &H4
  80. Public Const SWP_NOREDRAW = &H8
  81. Public Const SWP_NOACTIVATE = &H10
  82. Public Const SWP_FRAMECHANGED = &H20        '  The frame changed: send WM_NCCALCSIZE
  83. Public Const SWP_SHOWWINDOW = &H40
  84. Public Const SWP_HIDEWINDOW = &H80
  85. Public Const SWP_NOCOPYBITS = &H100
  86. Public Const SWP_NOOWNERZORDER = &H200      '  Don't do owner Z ordering
  87.  
  88. Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
  89. Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
  90.  
  91. ' SetWindowPos() hwndInsertAfter values
  92. Public Const HWND_TOP = 0
  93. Public Const HWND_BOTTOM = 1
  94. Public Const HWND_TOPMOST = -1
  95. Public Const HWND_NOTOPMOST = -2
  96.  
  97. Public Const CWP_ALL = 0
  98. Public Const CWP_SKIPINVISIBLE = 1
  99. Public Const CWP_SKIPDISABLED = 2
  100. Public Const CWP_SKIPTRANSPARENT = 4
  101.  
  102. Declare Function AdjustWindowRect& Lib "user32" (lpRect As RECT, ByVal dwStyle As Long, ByVal bMenu As Long)
  103. Declare Function AdjustWindowRectEx& Lib "user32" (lpRect As RECT, ByVal dsStyle As Long, ByVal bMenu As Long, ByVal dwEsStyle As Long)
  104. Declare Function AnyPopup& Lib "user32" ()
  105. Declare Function ArrangeIconicWindows& Lib "user32" (ByVal hwnd As Long)
  106. Declare Function AttachThreadInput& Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long)
  107. Declare Function BeginDeferWindowPos& Lib "user32" (ByVal nNumWindows As Long)
  108. Declare Function BringWindowToTop& Lib "user32" (ByVal hwnd As Long)
  109. Declare Function CascadeWindows% Lib "user32" (ByVal hwndParent As Long, ByVal wHow As Long, lpRect As RECT, ByVal cKids As Long, lpKids As Long)
  110. Declare Function CascadeWindowsByNum% Lib "user32" Alias "CascadeWindows" (ByVal hwndParent As Long, ByVal wHow As Long, ByVal lpRect As Long, ByVal cKids As Long, ByVal lpKids As Long)
  111. Declare Function ChildWindowFromPoint& Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long)
  112. Declare Function ChildWindowFromPointEx& Lib "user32" (ByVal hwndParent As Long, ByVal ptx As Long, ByVal pty As Long, ByVal uFlags As Long)
  113. Declare Function ClientToScreen& Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI)
  114. Declare Function CloseWindow& Lib "user32" (ByVal hwnd As Long)
  115. Declare Function CopyRect& Lib "user32" (lpDestRect As RECT, lpSourceRect As RECT)
  116. Declare Function DeferWindowPos& Lib "user32" (ByVal hWinPosInfo As Long, 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)
  117. Declare Function DestroyWindow& Lib "user32" (ByVal hwnd As Long)
  118. Declare Function DrawAnimatedRects& Lib "user32" (ByVal hwnd As Long, ByVal idAni As Long, lprcFrom As RECT, lprcTo As RECT)
  119. Declare Function EnableWindow& Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long)
  120. Declare Function EndDeferWindowPos& Lib "user32" (ByVal hWinPosInfo As Long)
  121. Declare Function EnumChildWindows& Lib "user32" (ByVal hwndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long)
  122. Declare Function EnumThreadWindows& Lib "user32" (ByVal dwThreadID As Long, ByVal lpfn As Long, ByVal lParam As Long)
  123. Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long)
  124. Declare Function EqualRect& Lib "user32" (lpRect1 As RECT, lpRect2 As RECT)
  125. Declare Function FindWindow& Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String)
  126. Declare Function FindWindowEx& Lib "user32" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As String, ByVal lpWindowName As String)
  127. Declare Function FlashWindow& Lib "user32" (ByVal hwnd As Long, ByVal bInvert As Long)
  128. Declare Function GetActiveWindow& Lib "user32" ()
  129. Declare Function GetCapture& Lib "user32" ()
  130. Declare Function GetClassInfo& Lib "user32" Alias "GetClassInfoA" (ByVal hInstance As Long, ByVal lpClassName As String, lpWndClass As WNDCLASS)
  131. Declare Function GetClassInfoEx& Lib "user32" Alias "GetClassInfoExA" (ByVal hInstance As Long, ByVal lpClassName As String, lpWndClassEx As WNDCLASSEX)
  132. Declare Function GetClassLong& Lib "user32" Alias "GetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long)
  133. Declare Function GetClassName& Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
  134. Declare Function GetClassWord& Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long)
  135. Declare Function GetClientRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
  136. Declare Function GetDesktopWindow& Lib "user32" ()
  137. Declare Function GetFocus& Lib "user32" ()
  138. Declare Function GetForegroundWindow& Lib "user32" ()
  139. Declare Function GetLastActivePopup& Lib "user32" (ByVal hwndOwnder As Long)
  140. Declare Function GetParent& Lib "user32" (ByVal hwnd As Long)
  141. Declare Function GetTopWindow& Lib "user32" (ByVal hwnd As Long)
  142. Declare Function GetUpdateRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long)
  143. Declare Function GetWindow& Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long)
  144. Declare Function GetWindowContextHelpId& Lib "user32" (ByVal hwnd As Long)
  145. Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long)
  146. Declare Function GetWindowPlacement& Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT)
  147. Declare Function GetWindowRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
  148. Declare Function GetWindowText& Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long)
  149. Declare Function GetWindowTextLength& Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long)
  150. Declare Function GetWindowWord% Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long)
  151. Declare Function InflateRect& Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
  152. Declare Function IntersectRect& Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT)
  153. Declare Function InvalidateRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT, ByVal bErase As Long)
  154. Declare Function InvalidateRectBynum& Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, ByVal lpRect As Long, ByVal bErase As Long)
  155. Declare Function IsChild& Lib "user32" (ByVal hwndParent As Long, ByVal hwnd As Long)
  156. Declare Function IsIconic& Lib "user32" (ByVal hwnd As Long)
  157. Declare Function IsRectEmpty& Lib "user32" (lpRect As RECT)
  158. Declare Function IsWindow& Lib "user32" (ByVal hwnd As Long)
  159. Declare Function IsWindowEnabled& Lib "user32" (ByVal hwnd As Long)
  160. Declare Function IsWindowUnicode& Lib "user32" (ByVal hwnd As Long)
  161. Declare Function IsWindowVisible& Lib "user32" (ByVal hwnd As Long)
  162. Declare Function IsZoomed& Lib "user32" (ByVal hwnd As Long)
  163. Declare Function LockWindowUpdate& Lib "user32" (ByVal hwndLock As Long)
  164. Declare Function MapWindowPoints& Lib "user32" (ByVal hwndFrom As Long, ByVal hwndTo As Long, lppt As POINTAPI, ByVal cPoints As Long)
  165. Declare Function MoveWindow& Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long)
  166. Declare Function OffsetRect& Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
  167. Declare Function OpenIcon& Lib "user32" (ByVal hwnd As Long)
  168. Declare Function PtInRect& Lib "user32" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long)
  169. Declare Function RedrawWindow& Lib "user32" (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long)
  170. Declare Function ReleaseCapture& Lib "user32" ()
  171. Declare Function ScreenToClient& Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI)
  172. Declare Function ScrollWindow& Lib "user32" (ByVal hwnd As Long, ByVal XAmount As Long, ByVal YAmount As Long, lpRect As RECT, lpClipRect As RECT)
  173. Declare Function ScrollWindowEx& Lib "user32" (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)
  174. Declare Function SetActiveWindow& Lib "user32" (ByVal hwnd As Long)
  175. Declare Function SetCapture& Lib "user32" (ByVal hwnd As Long)
  176. Declare Function SetClassLong& Lib "user32" Alias "SetClassLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
  177. Declare Function SetClassWord& Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long)
  178. Declare Function SetFocusAPI& Lib "user32" Alias "SetFocus" (ByVal hwnd As Long)
  179. Declare Function SetForegroundWindow& Lib "user32" (ByVal hwnd As Long)
  180. Declare Function SetParent& Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long)
  181. Declare Function SetRect& Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long)
  182. Declare Function SetRectEmpty& Lib "user32" (lpRect As RECT)
  183. Declare Function SetWindowContextHelpId& Lib "user32" (ByVal hwnd As Long, ByVal dwContextHelpId As Long)
  184. Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
  185. Declare Function SetWindowPlacement& Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT)
  186. Declare Function SetWindowPos& Lib "user32" (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)
  187. Declare Function SetWindowText& Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String)
  188. Declare Function SetWindowWord& Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long)
  189. Declare Function ShowOwnedPopups& Lib "user32" (ByVal hwnd As Long, ByVal fShow As Long)
  190. Declare Function ShowWindow& Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long)
  191. Declare Function ShowWindowAsync& Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long)
  192. Declare Function SubtractRect& Lib "user32" (lprcDst As RECT, lprcSrc1 As RECT, lprcSrc2 As RECT)
  193. Declare Function TileWindows% Lib "user32" (ByVal hwndParent As Long, ByVal wHow As Long, lpRect As RECT, ByVal cKids As Long, lpKids As Long)
  194. Declare Function TileWindowsBynum% Lib "user32" Alias "TileWindows" (ByVal hwndParent As Long, ByVal wHow As Long, ByVal lpRect As Long, ByVal cKids As Long, ByVal lpKids As Long)
  195. Declare Function UnionRect& Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT)
  196. Declare Function UpdateWindow& Lib "user32" (ByVal hwnd As Long)
  197. Declare Function ValidateRect& Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
  198. Declare Function ValidateRectBynum& Lib "user32" Alias "ValidateRect" (ByVal hwnd As Long, ByVal lpRect As Long)
  199. Declare Function WindowFromPoint& Lib "user32" (ByVal x As Long, ByVal y As Long)
  200.  
  201. Declare Function da& Lib "user32" Alias "DrawAnimatedRects" (ByVal hwnd As Long, ByVal idAni As Long, lprcFrom As SMALLRECT, lprcTo As SMALLRECT)
  202.  
  203.