注册 登录
编程论坛 Delphi论坛

请教怎样加一个按钮对象Button2

fairy1331 发布于 2006-05-26 16:15, 591 次点击
就是按钮Button1的单击事件里定义一个Form对象。然后创建后的窗体对象的事件怎么来写呢?!还有在上面加具体的按钮对象。如:

procedure TForm1.Button1Click(Sender: TObject);

var

Form2:TForm;

begin

Form2:=TForm.create(nil);

Form2.ShowModal;

end;

就是说怎么样写Form2的事件呢,还有就是在Form2上面加一个按钮对象Button2。

菜鸟求救!!!!
2 回复
#2
coldwave2006-05-28 13:27
procedure TForm1.Button1Click(Sender: TObject);
var
Form2:TForm;
Button2:Tbutton;
begin
Form2:=TForm.create(nil);
Button2:=Tbutton.create(self);
Form2.ShowModal;
end;
这样能生成button2。
你直接做好form2,在TForm1.Button1Click里面写Form2.ShowModal就行了,这多简单。
#3
coldwave2006-05-28 13:27
Form2.ShowModal前面加上Button2.parent:=Form2;
1