1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
| procedure TForm1.MoveSelection(Sender: TObject; Shift: TShiftState; X, Y: Integer); var source,dest: TRect; dy,dx: Integer; begin if(selected) then begin dx := X - dcursorx; dy := Y - dcursory;
if(x1 > x0) AND (y1 > y0) then begin source := Rect(x0,y0,x1,y1); dest := Rect(0,0,x1-x0,y1-y0); end; if(x1 < x0) AND (y1 > y0) then begin source := Rect(x1,y0,x0,y1); dest := Rect(0,0,x0-x1,y1-y0); end; if(x1 < x0) AND (y1 < y0) then begin source := Rect(x1,y1,x0,y0); dest := Rect(0,0,x0-x1,y0-y1); end; if(x1 > x0) AND (y1 < y0) then begin source := Rect(x0,y1,x1,y0); dest := Rect(0,0,x1-x0,y0-y1); end;
Image1.Canvas.Pen.Width := 0; Image1.Canvas.Pen.Color := clWhite; Image1.Canvas.Brush.Color := clWhite;
Image2.Width := source.Right - source.Left; Image2.Height := source.Bottom - source.Top; Image2.Left := dx; Image2.Top := dy;
Image2.Canvas.CopyRect(dest,Image1.Canvas,source); Image1.Canvas.Rectangle(source);
end; end; |