在我的项目中,我有两个表单(form1,form2),form1 是配置表单。
我想显示 Form1,当我们单击 Button1 时,显示 Form2 和 free(Release) Form1。我该怎么做?
我使用此代码。但是这个项目启动然后自动退出。一位朋友说因为应用程序消息循环从未启动,并且应用程序终止是因为主窗体不存在。我该如何解决这个问题?
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.CreateForm(TForm2, Form2);
Release;
end;
///
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Form1:= TForm1.Create(Application);
Application.Run;
end.