How can I capture a screen beneath my window except for my own window

Assuming I want to program a magnifying glass, how can I capture the contents of the screen excluding my own window? I know how to capture the screen with my window using BitBlt and Desktop DC.

And to make it clearer: I want to show the enlarged content in my window.

Edit: there seems to be no other solution than to hide my window (or client area) anyway, before I can capture the contents of the screen under my window. Apparently this makes my window flicker, which makes this script pretty worthless.

+6
source share
4 answers

In the capture process, set the AlphaBlend form AlphaBlend to true and AlphaBlendValue to 0. Keep in mind that this will make your form completely invisible.

+2
source

PrintWindow () is used for this, but it is not fast and does not work for all applications.

+1
source

You need to write a screenshot from the DC desktop to the 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 Uwe to this answer so that your form is invisible and you have ....

 FCapturedScreenShot:TBitmap; .... FCapturedScreenShot:=TBitmap.Create; .... AlphaBlend:=true; AlphaBlendValue:=0; CaptureScreenshot(FCapturedScreenShot); AlphaBlendValue:=False; 

use the captured screenshot for everything you need, you can assign it to a bitmap in another form or save it in an array of captured screens ...

+1
source

Try to minimize or hide the shape before capturing the screen and restore or display the shape after the capture screen

0
source

Source: https://habr.com/ru/post/891466/


All Articles