Results 1 to 2 of 2

Thread: hWnd of Child Windows

  1. #1

    Thread Starter
    Addicted Member bataeu's Avatar
    Join Date
    Nov 2000
    Location
    Walla Walla, Washington
    Posts
    144

    hWnd of Child Windows

    Does anyone know how to get the handle of a child window, not a window that I own either.

    I am hoping to be able to get other peoples child windows hWnds.

    Thanks in advance
    C, C++ and none of that MCF crap either!

  2. #2
    jim mcnamara
    Guest
    Try EnumChildWindows:

    Code:
    'in a form
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Me.AutoRedraw = True
        EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
    End Sub
    'in a module
    Declare Function GetDesktopWindow Lib "user32" () As Long
    Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim sSave As String
        'Get the windowtext length
        sSave = Space$(GetWindowTextLength(hwnd) + 1)
        'get the window text
        GetWindowText hwnd, sSave, Len(sSave)
        'remove the last Chr$(0)
        sSave = Left$(sSave, Len(sSave) - 1)
        If sSave <> "" Then Form1.Print sSave
        'continue enumeration
        EnumChildProc = 1
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width