]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
jpeg, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
R,newR:Trect;
x0,y0:integer;
bDrag:Boolean;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
with R do begin
Left :=0 ; Top :=0 ;
Right := Image1.Width ;
bottom := Image1.Height;
end;
newR:= R;
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
bDrag:=false;
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
bDrag:= True;
x0:= x;
y0:=y;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
dx,dy:Integer;
Canvas1:TCanvas;
begin
if not bDrag then exit;
dx := x-x0;
dy := y-y0;
with NewR do begin
left := R.left - dx;
top := R.Top- dy;
Right := R.Right -dx;
Bottom := R.Bottom-dy;
end;
canvas1:= Image1.Picture.Bitmap.canvas;
Image1.Picture.Bitmap.Canvas.CopyRect(R,canvas1,newR);
end;
end.