在form上画矩形后,怎么拾取该矩形,使其能随鼠标拖动而变化大小。 rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我有例子,留下邮件地址,我发给你。[email protected] 你可以用鼠标事件,DOWN事件是确定矩形的大小,UP事件时画矩形就可以了。或者自己做一个控件,就象本身带的SHAPE一样。 我刚做的例子你看看有没有帮助:代码如下:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;type TForm1 = class(TForm) Panel1: TPanel; procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } end;type pp = class(tpanel)end;var Form1: TForm1; x1,x2,oldx,oldy,y1,y2,foldx,foldy:integer; trace:boolean;implementation{$R *.dfm}procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);beginif trace = true thenbeginwith pp(panel1).Canvas dobeginrectangle(x1,y1,oldx,oldy);pen.Mode:=pmnot;//取反rectangle(x1,y1,x,y);oldx:=x;oldy:=y;end;end; end;procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);beginx1:=x;y1:=y;oldx:=x;oldy:=y;trace:=true;end;end. to zytangzhou: [email protected],3q! Windows服务程序里使用IdUdpServer 关于 delphi中bpl文件的问题 有拓朴显示数据的VCL控件吗?最好是免费的。 你是高手吗? 关于delphi调用VC编写的dll文件的问题。 哪有好的Delphi源代码下载? Client端一次只能只能传输1024字节,为什么? 救命——存取违例 三層結構中,用CORBA時,當我用ADOconnection時,客戶端CORBA無法connect為TURE,用BDE的就可以,為什么會是這樣的? 求帮忙远程弄下delphi代码 怎样用代码设置任务栏为自动隐藏? 关于CANVAS问题
[email protected]
DOWN事件是确定矩形的大小,UP事件时画矩形就可以了。或者自己做一个控件,就象本身带的SHAPE一样。
你看看有没有帮助:
代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Panel1: TPanel;
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
type
pp = class(tpanel)
end;
var
Form1: TForm1;
x1,x2,oldx,oldy,y1,y2,foldx,foldy:integer;
trace:boolean;
implementation{$R *.dfm}procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);begin
if trace = true then
begin
with pp(panel1).Canvas do
begin
rectangle(x1,y1,oldx,oldy);
pen.Mode:=pmnot;//取反
rectangle(x1,y1,x,y);
oldx:=x;
oldy:=y;
end;
end;
end;
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
x1:=x;
y1:=y;
oldx:=x;
oldy:=y;
trace:=true;
end;end.