home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples4 / ch19 / tstwnd.cls < prev    next >
Encoding:
Text File  |  1997-02-16  |  773 b   |  23 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "App"
  6. Attribute VB_Creatable = True
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9. ' copyright ⌐ 1997 by Desaware Inc. All Rights Reserved
  10.  
  11. Private Declare Function APIGetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  12. Private Declare Function APIGetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  13.  
  14.  
  15. Public Function GetWindowText(ByVal usewnd As Long) As String
  16.     Dim textlen As Long
  17.     Dim res$
  18.     textlen = APIGetWindowTextLength(usewnd) + 1
  19.     res$ = String$(textlen + 1, 0)
  20.     Call APIGetWindowText(usewnd, res$, textlen)
  21.     GetWindowText = res$
  22. End Function
  23.