in dotnet/WPF/ScreenCapture/ScreenCapture/WindowEnumerationHelper.cs [129:165]
public static bool IsWindowValidForCapture(IntPtr hwnd)
{
if (hwnd.ToInt32() == 0)
{
return false;
}
if (hwnd == GetShellWindow())
{
return false;
}
if (!IsWindowVisible(hwnd))
{
return false;
}
if (GetAncestor(hwnd, GetAncestorFlags.GetRoot) != hwnd)
{
return false;
}
var style = (WindowStyles)(uint)GetWindowLongPtr(hwnd, (int)GWL.GWL_STYLE).ToInt32();
if (style.HasFlag(WindowStyles.WS_DISABLED))
{
return false;
}
var cloaked = false;
var hrTemp = DwmGetWindowAttribute(hwnd, DWMWINDOWATTRIBUTE.Cloaked, out cloaked, Marshal.SizeOf<bool>());
if (hrTemp == 0 && cloaked)
{
return false;
}
return true;
}