Please check this code:
procedure ScreenShotBMP(DestBitmap : TBitmap; AActiveWindow: Boolean = True) ;
var
DC: HDC;
begin
if AActiveWindow then
DC := GetDC(GetForegroundWindow)
else
DC := GetDC(GetDesktopWindow);
try
DestBitmap.Width := GetDeviceCaps(DC, HORZRES);
DestBitmap.Height := GetDeviceCaps(DC, VERTRES);
BitBlt(DestBitmap.Canvas.Handle, 0, 0, DestBitmap.Width, DestBitmap.Height, DC, 0, 0, SRCCOPY);
finally
if AActiveWindow then
ReleaseDC(GetForegroundWindow, DC)
else
ReleaseDC(GetDesktopWindow, DC);
end;
end;
It generates screenshot properly, of Desktop or Active screen but computer stuck a little big during that operation.
I need app to make screenshots on regular time frames (less then one sec), but running this slows down computer.
It's not CPU consuming, taskmanager doesn't show any abnormal activity, simple entire system is stuck. No matter if I run this code inside main thread or another thread.
Is there any other method to create screenshot that won't slow down machine?
Thanks.