主题:[原创]随机BUTTON数组产生后...高分重谢
var
Form1: TForm1;
array_button:array of Tbutton;//随机BUTTON组动态申请
num_x,num_y:integer;
//随机产生BUTTONS组过程
procedure Tform1.G_Buttons();
var
i,n,x,y: integer;
begin
x:= num_x;//全局变量
y:= num_y;
n:=(num_x)*(num_y);
setlength(myarray1,n+1);
for i:=1 to n do
begin
array_button[i]:=Tbutton.create(self);
array_button[i].Parent:=form1;
array_button[i].height:=20;
array_button[i].width:=20;
array_button[i].Top:=50+((i-1) div x) *20;
array_button[i].left:=2+((i-1) mod y)*20;
array_button[i].Caption:=' ';
end;
end;
现在的问题是,我要定义一个array_button[i]的mousedown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);的事件,并且该事件要区分鼠标的左击 还是右击 来对应不同的代码
Form1: TForm1;
array_button:array of Tbutton;//随机BUTTON组动态申请
num_x,num_y:integer;
//随机产生BUTTONS组过程
procedure Tform1.G_Buttons();
var
i,n,x,y: integer;
begin
x:= num_x;//全局变量
y:= num_y;
n:=(num_x)*(num_y);
setlength(myarray1,n+1);
for i:=1 to n do
begin
array_button[i]:=Tbutton.create(self);
array_button[i].Parent:=form1;
array_button[i].height:=20;
array_button[i].width:=20;
array_button[i].Top:=50+((i-1) div x) *20;
array_button[i].left:=2+((i-1) mod y)*20;
array_button[i].Caption:=' ';
end;
end;
现在的问题是,我要定义一个array_button[i]的mousedown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);的事件,并且该事件要区分鼠标的左击 还是右击 来对应不同的代码