How can I capture screen under my own window excluding my own window

前端 未结 4 1012
情书的邮戳
情书的邮戳 2021-01-05 10:42

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

相关标签:
4条回答
  • 2021-01-05 10:58

    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.

    0 讨论(0)
  • 2021-01-05 11:09

    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...

    0 讨论(0)
  • 2021-01-05 11:09

    Try to minimize or hide you form before capture the screen and restore or show the form after capture screen

    0 讨论(0)
  • 2021-01-05 11:14

    You use PrintWindow() for that, but it is not fast and does not work for all applications.

    0 讨论(0)
提交回复
热议问题