diff --git a/PInvoke/User32/WinUser.Window.cs b/PInvoke/User32/WinUser.Window.cs index 1c0c5c15..729844a0 100644 --- a/PInvoke/User32/WinUser.Window.cs +++ b/PInvoke/User32/WinUser.Window.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Runtime.InteropServices; using System.Text; @@ -2996,11 +2997,9 @@ namespace Vanara.PInvoke public static extern bool EndTask(HWND hWnd, [MarshalAs(UnmanagedType.Bool)] bool fShutDown, [MarshalAs(UnmanagedType.Bool)] bool fForce); /// - /// /// Enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to /// an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the /// callback function returns FALSE. - /// /// /// /// Type: HWND @@ -3035,6 +3034,28 @@ namespace Vanara.PInvoke [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnumChildWindows(HWND hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam); + /// + /// Enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to + /// an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the + /// callback function returns FALSE. + /// + /// + /// Type: HWND + /// + /// A handle to the parent window whose child windows are to be enumerated. If this parameter is , this + /// function is equivalent to EnumWindows. + /// + /// + /// An ordered sequence of child window handles. + public static IList EnumChildWindows(this HWND hWndParent) + { + var children = new List(); + Win32Error.ThrowLastErrorIfFalse(EnumChildWindows(hWndParent, EnumProc, default)); + return children; + + bool EnumProc(HWND hwnd, IntPtr lParam) { children.Add(hwnd); return true; } + } + /// /// /// Enumerates all nonchild windows associated with a thread by passing the handle to each window, in turn, to an application-defined @@ -3402,6 +3423,17 @@ namespace Vanara.PInvoke [PInvokeData("winuser.h", MSDNShortId = "")] public static extern HWND GetCapture(); + /// + /// Retrieves the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved + /// handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows. + /// + /// A handle to a window. + /// + /// If the function succeeds, the return value is a window handle. If no window exists with the specified relationship to the + /// specified window, the return value is NULL. To get extended error information, call GetLastError. + /// + public static HWND GetChildWindow(this HWND hWnd) => GetWindow(hWnd, GetWindowCmd.GW_CHILD); + /// /// Retrieves information about a window class. ///