Delphi中的创建窗体的问题
在一个程序中,创建了两个窗体,分别为Form1和Form2,在Project->Options->Forms中将Form1设置为自动显示,而Form2设置为非自动显示。
我想在Form1中添加一个按钮,点击按钮会重新创建Form2,我用的是以下方法:
首先在Form1中的unit Unit1 ;下一行添加添加unit Unit2 ;
然后在Form1中的implementation的下一行添加uses Unit2;
最后点击Form1中的Button1,写入代码:
procedure TForm3.Button2Click(Sender: TObject);
begin
Application.CreateForm(TForm1, Form1);
end;
编译后出现下面两个错误:
[DCC Error] Unit1.pas(2): E2029 'INTERFACE' expected but 'UNIT' found
[DCC Fatal Error] 调用DLL.dpr(6): F2063 Could not compile used unit 'Unit1.pas'
这错误是怎么回事啊,刚看几天Delphi对这样的问题,不太明白,特来请教各位高手大哥大姐们!
以前用BCB感觉非常简单,添加以下头文件,然后
TForm *frm=new TForm2(Application);
frm->ShowModal();
就搞定了,用Delphi就搞不了了
[解决办法]
unit Unit2 ;//<-----你添加嘛啊?