创建一个新的按钮

哪位高手能够告诉我:
如何在点击一个按钮后,能够在生成一个新的label控件,并且能够把生成的新label控件移动到新的位置。最好能够写出代码。小弟先谢谢了。
[85 byte] By [countliu-liuzhen] at [2008-2-13]
# 1
with Tlabel1.Create(self) do
begin
left:=...;
high:=...;
width:=...;
parent:=form1;
end;
wjlsmail-小脖领 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 2
控制你按牛的移动

procedure TForm1.Button1MouseDown(……)
begin
ReleaseCapture;
Button2.Perform(WM_SYSCOMMAND,$F012,0);
end;
qiqi97-迷茫 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 3


我不懂,不过我帮你---UP
sowine-恐拜狼 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 4
procedure TForm1.MvButtonClick(sender);
begin
with Label1:=Tlabel.Create(self) do
begin
Left:=...;
Top :=...;
High:=...;
Width:=...;
Parent:=form1;
end;
end;
jianke5555-汐 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 5
procedure TForm1.MvButtonClick(sender);
begin
with Label1:=Tlabel.Create(self) do
begin
Left:=...;
Top :=...;
High:=...;
Width:=...;
Parent:=form1;
end;
end;

同一楼上!
dext-德克斯特 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 6
procedure TForm1.MvButtonClick(sender);
var Label1:Tlabel;
begin
with Label1:=Tlabel.Create(self) do
begin
Left:=...;
Top :=...;
High:=...;
Width:=...;
Parent:=form1;
end;
end;
# 7
************************主题:控件******************************
***************关于在窗体自动生成多个控件并用数组控制*************
******************关键:uses StdCtrls*********************
unit Unit1;

interface

uses
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.
# 8
可以现写一个Label的派生累
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;

yfyang-无云 at 2007-10-22 > top of Msdn China Tech,Delphi,VCL组件开发及应用...