全部博文(788)
分类:
2008-11-27 21:16:49
//参考如下代码
type
TForm1 = class(TForm)
Timer1: TTimer;
Image1: TImage;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FRect: TRect;
FBitmap: TBitmap;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
vDesktopCanvas: TCanvas;
begin
if (FRect.Left = Mouse.CursorPos.X) and (FRect.Top = Mouse.CursorPos.Y) then // 鼠标没有移动
Exit;
vDesktopCanvas := TControlCanvas.Create;
with vDesktopCanvas do try
Handle := GetWindowDC(GetDesktopWindow);
if FRect.Left >= 0 then Draw(FRect.Left, FRect.Top, FBitmap); // 恢复上次屏幕
FRect := Bounds(Mouse.CursorPos.X, Mouse.CursorPos.Y,
Image1.Picture.Width, Image1.Picture.Height);
FBitmap.Canvas.CopyRect(FBitmap.Canvas.ClipRect, vDesktopCanvas, FRect); // 保存本次绘制
Draw(FRect.Left, FRect.Top, Image1.Picture.Graphic);
finally
vDesktopCanvas.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 10;
FBitmap := TBitmap.Create;
FBitmap.Width := Image1.Picture.Width;
FBitmap.Height := Image1.Picture.Height;
FRect.Left := -1;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FBitmap.Free;
end;
抢分!
伴水占了位置,过来接分。
。。。。。。。