Windows Handle

The EnumChildWindows may not be recusive, so you may have to search the children of the children may making a call to EnumChildWindows on each child window found.
 
HJB417 said:
The EnumChildWindows may not be recusive, so you may have to search the children of the children may making a call to EnumChildWindows on each child window found.


Thanks, that was my next step and here is the result Only one of the Child windows found has a sibling and it is an edit window for a combo box. Man this is a pain, lol. So I am now Im not sure where to go from here, Any ideas. What if this window is opened in another thread, would that make a difference?

Thanks

ZeroEffect
 
I would use spy++ to get the handle of the window you want and then call EnumChildWindows recursively and see if it finds it.

As long as the windows belong to the same application, it wont matter which thread its in. All input is processed by one thread in gui apps... The message pump thread.
 
HJB417 said:
I would use spy++ to get the handle of the window you want and then call EnumChildWindows recursively and see if it finds it.

As long as the windows belong to the same application, it wont matter which thread its in. All input is processed by one thread in gui apps... The message pump thread.

This is how I have done it but it isnt found is there a better way of doing this?

Code:
    Public Function GetChildWindows(ByVal whnd As IntPtr) As IntPtr()

        EnumChildWindows(whnd, New EnumWindowsProc(AddressOf Me.EnumerateChildProc), 0)
     
    End Function


    Private Function EnumerateChildProc(ByVal Handle As IntPtr, ByVal i As Integer) As Boolean

        EnumChildWindows(Handle, New EnumWindowsProc(AddressOf Me.EnumerateSiblingProc), 0)

        Return True
    End Function

    Private Function EnumerateSiblingProc(ByVal Handle As IntPtr, ByVal i As Integer) As Boolean
        Dim rec1 As New Rectangle
        GetWindowRect(Handle, rec1)
        Dim WindowName As Integer = Convert.ToInt32("000103D6", 16) hex from Spy++
        Dim int32Handle As String = Handle.ToInt32
        WindowFound = Handle
        If int32Handle = WindowName Then
            MsgBox("Match")

             WindowFound = Handle

        End If
        Return True
    End Function

Thanks

ZeroEffect
 
Console app. I knew the handle of a deeply nested child window. Heres code to recursively call enumchildwindow.

[VB]
Imports System
Imports System.Collections
Imports System.Runtime.InteropServices

Module Module1

<DllImport("user32.dll", SetLastError:=True)> _
Function EnumChildWindows(ByVal window As IntPtr, ByVal callback As EnumWindowsProc, ByVal i As Integer) As Boolean
End Function

<DllImport("user32.dll", SetLastError:=True)> _
Function GetDesktopWindow() As IntPtr
End Function

<Serializable()> _
Delegate Function EnumWindowsProc(ByVal handle As IntPtr, ByVal i As Integer) As Boolean


Private childWindows As ArrayList

Sub Main()
arraylist to store handles of found child window.
childWindows = New ArrayList

the child handle I want to look for.
Dim childHandle As New IntPtr(4129470)

search the desktops child windows.
EnumChildWindows(GetDesktopWindow, New EnumWindowsProc(AddressOf EnumerateChildProc), 0)

output stats n facts.
Console.WriteLine("Desktop has {0:N0} child window(s).", childWindows.Count)
Console.WriteLine("Requested child window found: {0}", childWindows.Contains(childHandle))

End Sub

Private Function EnumerateChildProc(ByVal childWindowHandle As IntPtr, ByVal i As Integer) As Boolean
add the child windows handle to the collection.
childWindows.Add(childWindowHandle)

do stuff here if you want like check the properties of the child window
if its the window you want, just Return True because theres no need
to continue searching.

do a recursive call to retrieve the child window handles of the child window.
EnumChildWindows(childWindowHandle, New EnumWindowsProc(AddressOf EnumerateChildProc), 0)

Return True
End Function

End Module
[/VB]

Inside the EnumerateChildProc function, I would place code to determine if the childwindow is the window you want. If not, call EnumerateChildProc on the childwindow.
 
So here is what is going on. Im still unable to return this window, but there is a update availible for the software and they have built the window I want to find into the main window. Upside Ill be able to do what I wanted to do, downside I wasnt able to find the window I was looking for. Thank for your help and I did learn alot about finding windows and such.

Thanks again,

ZeroEffect
 
Back
Top