我必须捕获内容并且只捕获一个窗口的内容。像那样:
(由 ScreenCaptor 捕获)
但我的程序捕捉到了这一点:
我使用这段代码:
IntPtr ParenthWnd = GetForegroundWindow();
if (!ParenthWnd.Equals(IntPtr.Zero))
{
IntPtr prevChild = IntPtr.Zero;
IntPtr currChild = IntPtr.Zero;
while (true)
{
currChild = FindWindowEx(ParenthWnd, prevChild, null, null);
if (currChild == IntPtr.Zero) break;
result.Add(currChild);
label3.Text += currChild.ToString() + " _ ";
prevChild = currChild;
}
}
然后我选择我的子窗口,例如:
handle = result[0];
最后捕获屏幕截图:
RECT rect = new RECT();
GetWindowRect(handle, ref rect);
Bitmap image = new Bitmap(rect.Right - rect.Left, rect.Bottom - rect.Top);
using (Graphics graphics = Graphics.FromImage(image))
{
IntPtr hDC = graphics.GetHdc();
PrintWindow(new HandleRef(graphics, handle), hDC, 0);
graphics.ReleaseHdc(hDC);
}
当然我不能裁剪捕获的图像,因为不知道每个“边框”的大小
提前致谢