/// <summary> Find all windows that match the given filter </summary>
        /// <param name="filter"> A delegate that returns true for windows
        ///    that should be returned and false for windows that should
        ///    not be returned </param>
        public static IEnumerable <IntPtr> FindWindows(EnumWindowsProc filter = null)
        {
            var windows = new IntPtrEnumerable();

            EnumWindows((wnd, param) =>
            {
                if (filter?.Invoke(wnd, param) != false)
                {
                    // only add the windows that pass the filter
                    windows.Add(wnd);
                }
                // but return true here so that we iterate all windows
                return(true);
            }, IntPtr.Zero);

            return(windows);
        }