怎么在图片实现框选(象在桌面一样框选),得到框选的坐标(50)

A

aynes

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么在image控件上实现:用鼠标框选(象在桌面一样按住鼠标左键进行框选,有个虚框出来,框完后虚框消失,得到相应的坐标)
 
A

aynes

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Image1: TImage; Button1: TButton; Image2: TImage; procedure Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Image1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Button1Click(Sender: TObject); private { Private declarations } LeftTop,RightButtom : TPoint; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin LeftTop := Point(x,y); end; procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin RightButtom := Point(x,y); Image1.Canvas.Brush.Color := clBlack; Image1.Canvas.FrameRect(Rect(LeftTop,RightButtom)); end; 我这样作了以后,可以画框了,但是 只能鼠标左键弹起的时候画图,而且这个框是一直存在的,我的目的是:鼠标按住拖动的时候,会有一个矩形框显示,鼠标左键弹起的时候,画的框就消失,应该在MOVE中怎么改
 
E

elefan

Unregistered / Unconfirmed
GUEST, unregistred user!
放一shape控件,形状shape为stRectangle,在Image鼠标落下、移动、抬起时间控制shape的top,Left,Width,Height,Visible即可
 
A

aynes

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 

Similar threads

回复
0
查看
794
不得闲
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部