Assuming I would like to program a magnifier, how could I capture the content of the screen excluding my very own window ? I know how to capture the screen with my own windo
During the capture process set the forms AlphaBlend
property to true and the AlphaBlendValue
to 0. Be aware that this will make your form completely invisible.
You need to capture the screenshot from the DC of the desktop, into a bitmap in memory.
procedure CaptureScreenShot(acapture: TBitMap);
var c: TCanvas;
r: TRect;
begin
c:= TCanvas.Create;
c.Handle:= GetWindowDC (GetDesktopWindow);
try
r:= Rect(0,0,screen.width,screen.height);
acapture.Width:=screen.Width;
acapture.Height:=screen.Height;
acapture.Canvas.CopyRect(r, c, r);
finally
ReleaseDC(0, c.handle);
c.Free;
end;
end;
Add to this Uwe's answer to make your form invisible and you have....
FCapturedScreenShot:TBitmap;
....
FCapturedScreenShot:=TBitmap.Create;
....
AlphaBlend:=true;
AlphaBlendValue:=0;
CaptureScreenshot(FCapturedScreenShot);
AlphaBlendValue:=False;
use the captured screenshot for whatever you need, you might assign it over a bitmap in another form, or save it in an array of captured screens...
Try to minimize or hide you form before capture the screen and restore or show the form after capture screen
You use PrintWindow() for that, but it is not fast and does not work for all applications.