Unit1.pas
上传用户:juxian
上传日期:2013-04-01
资源大小:38k
文件大小:1k
源码类别:

驱动编程

开发平台:

Delphi

  1. unit Unit1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   ScrSpy;
  6. type
  7.   TForm1 = class(TForm)
  8.     ScreenSpy1: TScreenSpy;
  9.     procedure FormResize(Sender: TObject);
  10.     procedure ScreenSpy1ScreenBitmap(Sender: TObject;
  11.       const Block: TScreenBlock; LastScanline: Pointer; IsIFrame: Boolean);
  12.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  13.   private
  14.     { Private declarations }
  15.     XRate, YRate: Extended;
  16.   public
  17.     { Public declarations }
  18.   end;
  19. var
  20.   Form1: TForm1;
  21. implementation
  22. {$R *.DFM}
  23. procedure TForm1.FormResize(Sender: TObject);
  24. begin
  25.   XRate:= ClientWidth / ScreenSpy1.ScreenWidth;
  26.   YRate:= ClientHeight / ScreenSpy1.ScreenHeight;
  27. end;
  28. procedure TForm1.ScreenSpy1ScreenBitmap(Sender: TObject;
  29.   const Block: TScreenBlock; LastScanline: Pointer; IsIFrame: Boolean);
  30. Var
  31.   R: TRect;
  32. begin
  33.   R:= Rect(Round(Block.Bound.Left*XRate), Round(Block.Bound.Top*YRate), Round(Block.Bound.Right*XRate), Round(Block.Bound.Bottom*YRate));
  34.   Canvas.StretchDraw(R, Block.BMP);
  35. end;
  36. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  37. begin
  38.   ScreenSpy1.Active:= False;
  39. end;
  40. end.