with Tlabel1.Create(self) do begin left:=...; high:=...; width:=...; parent:=form1; end;
控制你按牛的移动procedure TForm1.Button1MouseDown(……) begin ReleaseCapture; Button2.Perform(WM_SYSCOMMAND,$F012,0); end;
procedure TForm1.MvButtonClick(sender); begin with Label1:=Tlabel.Create(self) do begin Left:=...; Top :=...; High:=...; Width:=...; Parent:=form1; end; end;
procedure TForm1.MvButtonClick(sender); begin with Label1:=Tlabel.Create(self) do begin Left:=...; Top :=...; High:=...; Width:=...; Parent:=form1; end; end;同一楼上!
procedure TForm1.MvButtonClick(sender); var Label1:Tlabel; begin with Label1:=Tlabel.Create(self) do begin Left:=...; Top :=...; High:=...; Width:=...; Parent:=form1; end; end;
************************主题:控件****************************** ***************关于在窗体自动生成多个控件并用数组控制************* ******************关键:uses StdCtrls********************* unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, stdctrls;//放置100个按纽,LABLE也一样 type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject); var i,j:integer; aBtn:array [1..10,1..10] of Tbutton; begin for i:=1 to 10 do for j:=1 to 10 do begin aBtn[i][j]:=Tbutton.Create(self); with aBtn[i][j] do begin left:=j*30; height:=20; top:=i*20; width:=30; parent:=form1; end; end; //在按纽上显示数字 for i:=1 to 10 do for j:=1 to 10 do begin aBtn[i][j].Caption:=inttostr(i-1)+inttostr(j-1); end; end; end.
begin
left:=...;
high:=...;
width:=...;
parent:=form1;
end;
begin
ReleaseCapture;
Button2.Perform(WM_SYSCOMMAND,$F012,0);
end;
begin
with Label1:=Tlabel.Create(self) do
begin
Left:=...;
Top :=...;
High:=...;
Width:=...;
Parent:=form1;
end;
end;
begin
with Label1:=Tlabel.Create(self) do
begin
Left:=...;
Top :=...;
High:=...;
Width:=...;
Parent:=form1;
end;
end;同一楼上!
var Label1:Tlabel;
begin
with Label1:=Tlabel.Create(self) do
begin
Left:=...;
Top :=...;
High:=...;
Width:=...;
Parent:=form1;
end;
end;
***************关于在窗体自动生成多个控件并用数组控制*************
******************关键:uses StdCtrls*********************
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, stdctrls;//放置100个按纽,LABLE也一样
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer;
aBtn:array [1..10,1..10] of Tbutton;
begin
for i:=1 to 10 do
for j:=1 to 10 do
begin
aBtn[i][j]:=Tbutton.Create(self);
with aBtn[i][j] do
begin
left:=j*30;
height:=20;
top:=i*20;
width:=30;
parent:=form1;
end;
end;
//在按纽上显示数字
for i:=1 to 10 do
for j:=1 to 10 do
begin
aBtn[i][j].Caption:=inttostr(i-1)+inttostr(j-1);
end;
end;
end.
TNewLabel=class(TLabel)
procedure WMNcHitTest(var msg : TMessage);message WM_NCHITTEST;
end;procedure TNewLabel.WMNcHitTest(var msg : TMessage);
begin
msg.result := HTCAPTION;
end;然后你就可以在你的程序里创建这个类了var
label : TNewLabel;
begin
label := TNewLabel.Create(Form1);
Label.Parent := Form1
end;