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 / ch19 / tstwnd.cls < prev    next >
Encoding:
Visual Basic class definition  |  1997-02-16  |  830 b   |  25 lines

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