admin管理员组文章数量:1415476
I'm trying to capture the desktop screenshot. However, I keep getting a black rectangle. I've also tried plugging out my 2nd monitor to no success, in case it was capturing the laptop screen (which is non-displaying). I've also tried to run the app in Administrator mode with no success.
I've searched the forum with no success, and I want to avoid adding more external libraries for a simple screen capture.
Using Delphi 12.1, Windows 11, 64-bit Firemonkey app.
const
CAPTUREBLT = $40000000; // no difference whether used
var
ScreenBitmap: TBitmap;
ScreenDC: HDC;
begin
ScreenBitmap := TBitmap.Create;
try
ScreenBitmap.SetSize(300, 300);
ScreenDC := GetDC(0); // Get the screen DC
try
BitBlt(ScreenBitmap.Handle, 0, 0, ScreenBitmap.Width, ScreenBitmap.Height,
ScreenDC, Round(aRect.Left), Round(aRect.Top), SRCCOPY{ or CAPTUREBLT});
ScreenBitmap.SaveToFile('test.bmp');
finally
ReleaseDC(0, ScreenDC);
end;
finally
ScreenBitmap.Free;
end;
end;
本文标签: Delphi screen capture part of current screenStack Overflow
版权声明:本文标题:Delphi screen capture part of current screen - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745166682a2645724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论