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

驱动编程

开发平台:

Delphi

  1. unit clnMain;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   ScrSpy;
  6. type
  7.   TForm1 = class(TForm)
  8.     ScreenPlayer1: TScreenPlayer;
  9.     procedure ScreenPlayer1HeaderUpdate(Sender: TObject);
  10.     procedure ScreenPlayer1ScreenBitmap(Sender: TObject;
  11.       const Block: TScreenBlock);
  12.     procedure FormResize(Sender: TObject);
  13.     procedure FormCreate(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.     XRate, YRate: Extended;
  17.     HasServer: Boolean;
  18.   public
  19.     { Public declarations }
  20.   end;
  21. var
  22.   Form1: TForm1;
  23. implementation
  24. {$R *.DFM}
  25. procedure TForm1.ScreenPlayer1HeaderUpdate(Sender: TObject);
  26. begin
  27.   HasServer:= True;
  28.   XRate:= ClientWidth / ScreenPlayer1.ScreenWidth;
  29.   YRate:= ClientHeight / ScreenPlayer1.ScreenHeight;
  30. end;
  31. procedure TForm1.ScreenPlayer1ScreenBitmap(Sender: TObject;
  32.   const Block: TScreenBlock);
  33. Var
  34.   R: TRect;
  35. begin
  36.   R:= Rect(Round(Block.Bound.Left*XRate), Round(Block.Bound.Top*YRate), Round(Block.Bound.Right*XRate), Round(Block.Bound.Bottom*YRate));
  37.   Canvas.StretchDraw(R, Block.BMP);
  38. end;
  39. procedure TForm1.FormResize(Sender: TObject);
  40. begin
  41.   If HasServer then
  42.     ScreenPlayer1HeaderUpdate(Sender);
  43. end;
  44. procedure TForm1.FormCreate(Sender: TObject);
  45. begin
  46.   HasServer:= False;
  47. end;
  48. end.