一小段代码,怎样改?(35分)

  • 主题发起人 主题发起人 facat
  • 开始时间 开始时间
F

facat

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure newform.myclick(Sender: TObject);
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
newform:tform;
bt:tbutton;
begin
newform:=tform.Create(form1);
bt:=tbutton.Create(newform);
with bt do
begin
parent:=newform;
caption:='sdfs';
end;
newform.ShowModal;
end;

procedure tnewform.myclick(Sender: TObject);
begin
showmessage('sdfs');
end;

end.
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure myclick(Sender: TObject);
end;

var
Form1: TForm1;

implementation

{$R *.DFM}


procedure Tform1.myclick(Sender: TObject);
begin
showmessage('sdfs');
end;

procedure TForm1.Button1Click(Sender: TObject);

var
newform:tform;
bt:tbutton;
begin
newform:=tform.Create(form1);
bt:=tbutton.Create(newform);
with bt do
begin
parent:=newform;
caption:='sdfs';
onclick:=myclick;
end;
newform.ShowModal;
end;

end.

 
接受答案了.
 

Similar threads

后退
顶部