//get the sub windows of specific handle. public static List <IntPtr> GetSubWindows(IntPtr parent) { List <IntPtr> windowsList = new List <IntPtr>(); GCHandle gch = GCHandle.Alloc(windowsList, GCHandleType.Normal); Win32API.EnumWindowEventHandler callbackProc = new Win32API.EnumWindowEventHandler(EnumWindows); Win32API.EnumWindows(callbackProc, (IntPtr)gch); if (parent != IntPtr.Zero && windowsList.Count > 0) { for (int i = 0; i < windowsList.Count; i++) { IntPtr handle = windowsList[i]; if (parent != Win32API.GetParent(handle)) { windowsList.Remove(handle); i--; } } } return(windowsList); }
//get the sub windows of specific handle. public static List<IntPtr> GetSubWindows(IntPtr parent) { List<IntPtr> windowsList = new List<IntPtr>(); GCHandle gch = GCHandle.Alloc(windowsList, GCHandleType.Normal); Win32API.EnumWindowEventHandler callbackProc = new Win32API.EnumWindowEventHandler(EnumWindows); Win32API.EnumWindows(callbackProc, (IntPtr)gch); if (parent != IntPtr.Zero && windowsList.Count > 0) { for (int i = 0; i < windowsList.Count; i++) { IntPtr handle = windowsList[i]; if (parent != Win32API.GetParent(handle)) { windowsList.Remove(handle); i--; } } } return windowsList; }