private static bool Filter(int hwnd, int lparam, out ApplicationWindow window)
        {
            window = null;
            var iHwnd = new IntPtr(hwnd);

            StringBuilder title = new StringBuilder(256);
            User32.GetWindowText(hwnd, title, 256);
            var t = title.ToString();
            //Skip if the window does not have a caption.
            if (t.Length == 0)
                return true;

            //Skip if parent is not the desktop.
            var parentHwnd = User32.GetParent(iHwnd);
            if (!parentHwnd.Equals(new IntPtr(0)))
                return true;

            if (!User32.KeepWindowHandleInAltTabList(iHwnd))
                return true;

            //Skip if the window is not visible but not minimized and has SW_HIDE (0) style.
            var placement = new WINDOWPLACEMENT();
            User32.GetWindowPlacement(iHwnd, ref placement);
            if (!User32.IsWindowVisible(hwnd) && !User32.IsIconic(iHwnd) && placement.flags == 0)
                return true;

            var info = new WINDOWINFO();
            info.cbSize = (uint)Marshal.SizeOf(info);
            User32.GetWindowInfo(iHwnd, ref info);
            //skip window if it's really small (usually an indicator it's not a alt tab candidate window.
            if (info.rcWindow.Width <= 10 && info.rcWindow.Height <= 10)
                return true;

            window = ApplicationWindows.GetApplicationWindow(hwnd, lparam);

            return true;
        }
Exemple #2
0
 public static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi);