K
kemble
Unregistered / Unconfirmed
GUEST, unregistred user!
想动态创建一个Button,代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
btn:TButton;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.btn1Click(Sender: TObject);
begin
btn:= tButton.Create(Self);
btn.Left:=Form1.Width div 2;
btn.Top:=Form1.Height div 2;
btn.Caption:='Hello World!';
btn.Visible := true;
end;
end.
但是,这个Button怎么也显示不出来,请问这是怎么回事呢???
哪位大侠能把调试通的代码贴出来吗??
多谢!!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
btn:TButton;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.btn1Click(Sender: TObject);
begin
btn:= tButton.Create(Self);
btn.Left:=Form1.Width div 2;
btn.Top:=Form1.Height div 2;
btn.Caption:='Hello World!';
btn.Visible := true;
end;
end.
但是,这个Button怎么也显示不出来,请问这是怎么回事呢???
哪位大侠能把调试通的代码贴出来吗??
多谢!!!