delphi,窗口显示
有form1(unit1),form2(unit2),form3(unit3);在form1和form2中均有一个button按钮我的目的是,form1中点击button...
有form1(unit1),form2(unit2),form3(unit3) ;在form1和form2中均有一个button按钮
我的目的是,form1中点击button显示form2,然后再form2在点击button显示form3.
代码:
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 }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.show;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
form3.show;
end;
end.
运行后,form1中点击button可以显示form2,但是在form2中点击button,出现access violation错误。
我在form3.show前面加了句Form3:=Tform3.Create(self);的话,在form2中点击button可以显示form3。但是,我是先建好form3,保存为unit3,然后再unit2中 uses unit3 调用的啊,应该不用添加这句。 我问的是不是很无厘头啊! 展开
我的目的是,form1中点击button显示form2,然后再form2在点击button显示form3.
代码:
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 }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2,unit3;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.show;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
form3.show;
end;
end.
运行后,form1中点击button可以显示form2,但是在form2中点击button,出现access violation错误。
我在form3.show前面加了句Form3:=Tform3.Create(self);的话,在form2中点击button可以显示form3。但是,我是先建好form3,保存为unit3,然后再unit2中 uses unit3 调用的啊,应该不用添加这句。 我问的是不是很无厘头啊! 展开
2个回答
展开全部
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 }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.Show;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Form3.Show;
end;
end.
我这样运行是没问题的
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 }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.Show;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Form3.Show;
end;
end.
我这样运行是没问题的
追问
你的意思是,跟我代码一样,你是可以运行的?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询