var draw:boolean;
arect:trect;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
begin
DoubleBuffered:=True;
arect:=Rect(-20+x-1,-20+y-1,21+x,21+y);
image1.Canvas.Pen.Color := ClBlack ;
image1.Canvas.Brush.Color := ClBlack ;
image2.Canvas.CopyRect(Rect(0,0,42,42),image1.Canvas,Rect(-20+x-1,-20+y-1,21+x,21+y));
image2.Canvas.Pen.Color := ClBlack ;
image2.Canvas.PenPos := Point(0,0);
image2.Canvas.Pen.Color := ClWhite;
image2.Canvas.LineTo(0,41);
image2.Canvas.Pen.Color := ClBlack ;
image2.Canvas.LineTo(41,41);
image2.Canvas.LineTo(41,0);
image2.Canvas.Pen.Color := ClWhite ;
image2.Canvas.LineTo(0,0);
image1.Canvas.CopyRect(Rect(-21+x,-21+y,21+x,21+y),image2.Canvas,Rect(0,0,42,42));
draw:=true;
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft then
begin
draw:=false;
arect:=Rect(-20+x-1,-20+y-1,21+x,21+y);
image1.Canvas.CopyRect(arect,image3.Canvas,arect);
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if draw then
begin
image1.Canvas.CopyRect(arect,image3.Canvas,arect);
DoubleBuffered:=True;
arect:=Rect(-21+x,-21+y,21+x,21+y);
image1.Canvas.Pen.Color := ClBlack ;
image1.Canvas.Brush.Color := ClBlack ;
image2.Canvas.CopyRect(Rect(0,0,42,42),image1.Canvas,arect);
image2.Canvas.Pen.Color := ClBlack ;
image2.Canvas.PenPos := Point(0,0);
image2.Canvas.Pen.Color := ClWhite;
image2.Canvas.LineTo(0,41);
image2.Canvas.Pen.Color := ClBlack ;
image2.Canvas.LineTo(41,41);
image2.Canvas.LineTo(41,0);
image2.Canvas.Pen.Color := ClWhite ;
image2.Canvas.LineTo(0,0);
image1.Canvas.CopyRect(arect,image2.Canvas,Rect(0,0,42,42));
end;
end;
这个应该可以吧,image1和image3中放了一样的图
如果还不对,我真是不明白你的意思了~