【问题标题】:Full screenshot of a window一个窗口的完整屏幕截图
【发布时间】:2011-10-31 16:15:24
【问题描述】:

我正在使用此代码创建指定窗口的屏幕截图(无论是否处于活动状态)

function WndScreen(const h: HWND; const bmp: TBitmap): boolean;
var
  Src, Dst: HDC;
  R: TRect;
  Width, Height: Integer;
  B: HBITMAP;
  Old: HGDIOBJ;
begin
  Src := GetDC(h);
  GetWindowRect(h, R);
  Width := R.Right - R.Left;
  Height := R.Bottom - R.Top;
  Dst := CreateCompatibleDC(Src);
  B := CreateCompatibleBitmap(Src, Width, Height);
  Old := SelectObject(Dst, B);
  BitBlt(Dst, 0, 0, Width, Height, Src, 0, 0, SRCCOPY);
  SelectObject(Dst, Old);
  DeleteDC(Dst);
  ReleaseDC(h, Src);

  bmp.Width := Width;
  bmp.Height := Height;
  bmp.Handle := B;

  DeleteObject(B);
end;

现在假设窗口有一个组合框。当我单击组合框并展开列表时,我的屏幕截图中不包含列表内容。

您知道创建全窗口屏幕截图的任何方法吗?

【问题讨论】:

  • 不使用 Alt+PtrScr 的任何原因?
  • 我想以编程方式创建一个窗口的屏幕截图,这就是原因。
  • 您可以执行全屏捕获的任何操作,然后使用窗口的坐标裁剪出您想要的内容。
  • 除非组合框的边界超出父窗口的边界,@Chris。

标签: delphi winapi screenshot


【解决方案1】:

看看PrintWindow() 函数,而不是直接使用BitBlt()。尽管它的名字,PrintWindow() 可用于将屏幕截图捕获到位图,它不仅限于打印。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    相关资源
    最近更新 更多