毕设在即,十万火急 比较复杂,主要用到mousedown、mouseup、mousemove,onpaint事件,高为四个状态,无、画、移、变换在设一个属性,记录图形方式(自己定义)还有,定义一个数据,记录图形数据(很重要),其它的,你作吧,作了你就知道其实不难的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.定义图形对象包括属性以及改变这些属性的方法。2.定义选取对象可以选中这些图形对象。3.截取鼠标消息,尤其是MouseMove,调用选取对象的相应方法改变图形对象的属性。什么学校,要作这样的毕业设计?! 使用Windows API 函数DrawFocusRect。DrawFocusRect 函数执行时使用XOR函数,所以选择同样的矩形区域两次,矩形区域会被擦除。矩形区域一直保持可见。例子:typeTForm1 = 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;varForm1: TForm1;implementation{$R *.DFM}function MakeRect(Pt1 : TPoint;Pt2 : TPoint) : TRect;beginif pt1.x < pt2.x then beginResult.Left := pt1.x;Result.Right := pt2.x;end else beginResult.Left := pt2.x;Result.Right := pt1.x;end;if pt1.y < pt2.y then beginResult.Top := pt1.y;Result.Bottom := pt2.y;end else beginResult.Top := pt2.y;Result.Bottom := pt1.y;end;end;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);beginif Captured thenDrawFocusRect(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);beginif Capturing then beginDrawFocusRect(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);beginCapturing := false;end; 谢谢各位的帮助,不过可能是我没说清楚目前的情况:已经实现了在image上画矩形,并且实现了拖动这个划定的矩形现在的问题:如何实现把image上的矩形区域内的图象跟着矩形走,并且原矩形 内为白色我的想法:在矩形的位置生成一个同样大小的image1,把矩形内的图形copyrect在image1上,并且底下的image的矩形内变为白色,当鼠标点在矩形内时可以拖动生成的image1但是想法和实现是有差距的,请高手指点 获取网站验证码的图片文件 我机器上设置了多个ip地址(一个网卡),我如何设置当前使用的ip.(跪求解决) DLL调用退出时的错误! 一个关于DELPHI连接ACCESS的问题 如何获得一个硬盘分区的序列号???? 一个关于Delphi调用AWE的问题! 紧急情况! delphi还能用多少年?它是标准化的吗?别像VB一样,半路被甩了! 高分求教,在软件中怎么实现多线程技术? 向高手请教有关frame方面的问题?????????????? 用Delphi作网页用IE浏览不行 如何判断数据库中的一个记录的一个字段的值是否为空?
2.定义选取对象可以选中这些图形对象。
3.截取鼠标消息,尤其是MouseMove,调用选取对象的相应方法改变图形对象的属性。
什么学校,要作这样的毕业设计?!
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;
目前的情况:已经实现了在image上画矩形,并且实现了拖动这个划定的矩形
现在的问题:如何实现把image上的矩形区域内的图象跟着矩形走,并且原矩形 内为白色
我的想法:在矩形的位置生成一个同样大小的image1,把矩形内的图形copyrect在image1上,并且底下的image的矩形内变为白色,当鼠标点在矩形内时可以拖动生成的image1
但是想法和实现是有差距的,请高手指点