O
only_delphi
Unregistered / Unconfirmed
GUEST, unregistred user!
本人写了一个过程,把该过程赋给一对象事件。
参数怎么设置,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Shape1: TShape;
Edit1: TEdit;
Shape2: TShape;
Button2: TButton;
procedure set_around(Sender: Tcontrol);
procedure set_MouseDown(Sender: Tcontrol
Shift: TShiftState
X, Y: Integer);
procedure Shape1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Button1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Button1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Button1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Shape1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Shape1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Shape2MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Shape2MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Shape2MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
procedure set_left_top(Sender: Tcontrol);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
flag:boolean;
old_x,old_y:integer;
implementation
{$R *.dfm}
procedure TForm1.set_around(Sender: Tcontrol);
begin
shape1.Left:=sender.Left-3;
shape1.top:=sender.top-3;
shape2.Left:=sender.Left +sender.Width div 2;
shape2.Top :=shape1.Top-2;
//shape1.Left:=sender.Left;
//shape1.Left:=sender.Left;
end;
procedure TForm1.Shape1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=false;
end;
procedure TForm1.FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
edit1.Text:=inttostr(shape2.top);
end;
procedure TForm1.Button1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
if flag then
begin
//shape1.Left:=button1.Left+button1.Width div 2;
//shape1.Top:=button1.Top-4;
button1.Left:=button1.Left + (x-old_x);
button1.Top:=button1.Top +(y-old_y);
set_around(button1);
end;
end;
procedure TForm1.Button1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
old_x:=x;
old_y:=y;
end;
procedure TForm1.Button1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=false;
end;
procedure TForm1.Shape1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
if flag then
begin
shape1.Top:=shape1.Top+y;
shape1.Left:=shape1.Left+x;
button1.Height:=button1.Height - y;
button1.Top:=button1.Top+y;
button1.Left:=shape1.Left;
button1.Width:=button1.Width-x;
// set_around(button1);
end;
end;
procedure TForm1.Shape1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
end;
procedure TForm1.set_left_top(Sender: Tcontrol);
begin
//sender.Left:=sender.Left+old_x+x;
end;
procedure TForm1.Shape2MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=false;
end;
procedure TForm1.Shape2MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
if flag then
begin
shape2.Top:=shape2.Top+y;
button1.Height:=button1.Height - y;
button1.Top:=button1.Top+y;
// set_around(button1);
end;
end;
procedure TForm1.Shape2MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
end;
procedure TForm1.set_MouseDown(Sender: Tcontrol
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
old_x:=x;
old_y:=y;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
shape1.OnMouseDown:=set_mousedown(此处的参数怎样写);
// set_MouseDown();
end;
end.
参数怎么设置,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Shape1: TShape;
Edit1: TEdit;
Shape2: TShape;
Button2: TButton;
procedure set_around(Sender: Tcontrol);
procedure set_MouseDown(Sender: Tcontrol
Shift: TShiftState
X, Y: Integer);
procedure Shape1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Button1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Button1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Button1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Shape1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Shape1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Shape2MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure Shape2MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
procedure Shape2MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
procedure set_left_top(Sender: Tcontrol);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
flag:boolean;
old_x,old_y:integer;
implementation
{$R *.dfm}
procedure TForm1.set_around(Sender: Tcontrol);
begin
shape1.Left:=sender.Left-3;
shape1.top:=sender.top-3;
shape2.Left:=sender.Left +sender.Width div 2;
shape2.Top :=shape1.Top-2;
//shape1.Left:=sender.Left;
//shape1.Left:=sender.Left;
end;
procedure TForm1.Shape1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=false;
end;
procedure TForm1.FormMouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
edit1.Text:=inttostr(shape2.top);
end;
procedure TForm1.Button1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
if flag then
begin
//shape1.Left:=button1.Left+button1.Width div 2;
//shape1.Top:=button1.Top-4;
button1.Left:=button1.Left + (x-old_x);
button1.Top:=button1.Top +(y-old_y);
set_around(button1);
end;
end;
procedure TForm1.Button1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
old_x:=x;
old_y:=y;
end;
procedure TForm1.Button1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=false;
end;
procedure TForm1.Shape1MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
if flag then
begin
shape1.Top:=shape1.Top+y;
shape1.Left:=shape1.Left+x;
button1.Height:=button1.Height - y;
button1.Top:=button1.Top+y;
button1.Left:=shape1.Left;
button1.Width:=button1.Width-x;
// set_around(button1);
end;
end;
procedure TForm1.Shape1MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
end;
procedure TForm1.set_left_top(Sender: Tcontrol);
begin
//sender.Left:=sender.Left+old_x+x;
end;
procedure TForm1.Shape2MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=false;
end;
procedure TForm1.Shape2MouseMove(Sender: TObject
Shift: TShiftState
X,
Y: Integer);
begin
if flag then
begin
shape2.Top:=shape2.Top+y;
button1.Height:=button1.Height - y;
button1.Top:=button1.Top+y;
// set_around(button1);
end;
end;
procedure TForm1.Shape2MouseDown(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
end;
procedure TForm1.set_MouseDown(Sender: Tcontrol
Shift: TShiftState
X, Y: Integer);
begin
flag:=true;
old_x:=x;
old_y:=y;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
shape1.OnMouseDown:=set_mousedown(此处的参数怎样写);
// set_MouseDown();
end;
end.