【问题标题】:How do I capture desktop screenshot behind full screen form?如何在全屏形式后面捕获桌面屏幕截图?
【发布时间】:2013-09-17 07:41:31
【问题描述】:

我有一个全屏表单来阻止所有输入。如何捕获此表单后面的所有桌面的屏幕截图?换句话说,如何在不出现屏幕前的这种形式的情况下获取打印屏幕?

我正在编写一个远程访问软件。 我需要在屏幕上显示技术支持信息并在访问期间阻止所有输入,以便分析师安静地工作 - 例如 VNC 可以选择关闭显示器,Dameware 可以选择阻止输入。

在此锁定屏幕后还有另一种远程工作方式吗?

【问题讨论】:

  • 让您的表单透明化?
  • 如果其他窗口在您的窗口下方,为什么它们会打扰绘画?
  • 隐藏表格做截图然后显示表格?
  • 仅供参考,有更好的选择来阻止输入而不是在前面放置表单。
  • 使用全屏表单块并然后想从下面截屏?你在做什么???? ;-)

标签: forms delphi screenshot capture behind


【解决方案1】:

虽然我完全同意评论者的观点,但使用全屏表单阻止用户输入并不是一个好主意,这里有一些代码可以帮助您入门。代码假定屏幕尺寸为 1920 x 1200。

unit Unit152;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm152 = class( TForm )
    Timer1: TTimer;
    procedure Timer1Timer( Sender: TObject );
    procedure FormCreate( Sender: TObject );
  private
    { Private declarations }
    DesktopBMP: TBitmap;
    procedure WMEraseBkgnd( var Message: TWMEraseBkgnd ); message WM_ERASEBKGND;
  protected
    procedure Paint; override;
  public
    { Public declarations }

  end;

var
  Form152: TForm152;

implementation

{$R *.dfm}
{ TForm152 }

procedure TForm152.FormCreate( Sender: TObject );
begin
  DesktopBMP := TBitmap.Create;
  DesktopBMP.SetSize( 1920, 1200 );
end;

procedure TForm152.Paint;
begin
  inherited;
  Canvas.Draw( 0, 0, DesktopBMP );
end;

procedure TForm152.Timer1Timer( Sender: TObject );
begin
  // alternatively a simple Invalidate would do here, but then
  // all other windows would not redraw
  Width := 0;
  Height := 0;
  Width := 1920;
  Height := 1200;
end;

procedure TForm152.WMEraseBkgnd( var Message: TWMEraseBkgnd );
var
  DesktopDC: HDC;
  DesktopHwnd: Hwnd;
  DesktopCanvas: TCanvas;
begin
  DesktopHwnd := GetDesktopWindow;
  DesktopDC := GetDC( DesktopHwnd );
  try
    DesktopCanvas := TCanvas.Create;
    DesktopCanvas.Handle := DesktopDC;
    DesktopBMP.Canvas.CopyRect( Rect( 0, 0, 1919, 1199 ), DesktopCanvas, Rect( 0, 0, 1919, 1199 ) );
  finally
    DesktopCanvas.Free;
    ReleaseDc( DesktopHwnd, DesktopDC );
  end;
  Message.Result := 1;
  inherited;
end;

end.

DFM 如下所示:

object Form152: TForm152
  Left = 2296
  Top = 103
  BorderStyle = bsNone
  Caption = 'Form152'
  ClientHeight = 699
  ClientWidth = 1289
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  WindowState = wsMaximized
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object Timer1: TTimer
    Interval = 10
    OnTimer = Timer1Timer
    Left = 640
    Top = 360
  end
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    • 2023-04-07
    • 1970-01-01
    • 2010-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多