比较复杂,主要用到mousedown、mouseup、mousemove,onpaint事件,
高为四个状态,无、画、移、变换
在设一个属性,记录图形方式(自己定义)
还有,定义一个数据,记录图形数据(很重要),
其它的,你作吧,作了你就知道其实不难的。

解决方案 »

  1.   

    1.定义图形对象包括属性以及改变这些属性的方法。
    2.定义选取对象可以选中这些图形对象。
    3.截取鼠标消息,尤其是MouseMove,调用选取对象的相应方法改变图形对象的属性。
    什么学校,要作这样的毕业设计?!
      

  2.   

    使用Windows API 函数DrawFocusRect。DrawFocusRect 函数执行时使用XOR函数,所以选择同样的矩形区域两次,矩形区域会被擦除。矩形区域一直保持可见。例子:type
    TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    private
    { 局部声明 }
    Capturing : bool;
    Captured : bool;
    StartPlace : TPoint;
    EndPlace : TPoint;
    public
    { 公共声明 }
    end;var
    Form1: TForm1;implementation{$R *.DFM}function MakeRect(Pt1 : TPoint;
    Pt2 : TPoint) : TRect;
    begin
    if pt1.x < pt2.x then begin
    Result.Left := pt1.x;
    Result.Right := pt2.x;
    end else begin
    Result.Left := pt2.x;
    Result.Right := pt1.x;
    end;
    if pt1.y < pt2.y then begin
    Result.Top := pt1.y;
    Result.Bottom := pt2.y;
    end else begin
    Result.Top := pt2.y;
    Result.Bottom := pt1.y;
    end;
    end;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin
    if Captured then
    DrawFocusRect(Form1.Canvas.Handle,
    MakeRect(StartPlace,
    EndPlace));
    StartPlace.x := X;
    StartPlace.y := Y;
    EndPlace.x := X;
    EndPlace.y := Y;
    DrawFocusRect(Form1.Canvas.Handle,
    MakeRect(StartPlace,
    EndPlace));
    Capturing := true;
    Captured := true;
    end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    begin
    if Capturing then begin
    DrawFocusRect(Form1.Canvas.Handle,
    MakeRect(StartPlace,
    EndPlace));
    EndPlace.x := X;
    EndPlace.y := Y;
    DrawFocusRect(Form1.Canvas.Handle,
    MakeRect(StartPlace,
    EndPlace));
    end;end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    begin
    Capturing := false;
    end;
      

  3.   

    谢谢各位的帮助,不过可能是我没说清楚
    目前的情况:已经实现了在image上画矩形,并且实现了拖动这个划定的矩形
    现在的问题:如何实现把image上的矩形区域内的图象跟着矩形走,并且原矩形   内为白色
    我的想法:在矩形的位置生成一个同样大小的image1,把矩形内的图形copyrect在image1上,并且底下的image的矩形内变为白色,当鼠标点在矩形内时可以拖动生成的image1
    但是想法和实现是有差距的,请高手指点