P
plzh
Unregistered / Unconfirmed
GUEST, unregistred user!
这个问题一直困扰着我。
三个form, form1,form2,form3,其中form1 为主窗口,form2,form3属于
available forms.
在form1中打开form2,在form2 中打开form3,在form3中更改form2中Tlabel
的caption.每次运行到更改语句时出错。请指教我怎样才能达到目的。
代码如下:
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 }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Form2:TForm2;
begin
Form2:=TForm2.Create(self);
Form2.Show;
end;
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit3;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
var
Form3:tFORM3;
begin
Form3:=TForm3.create(self);
Form3.show;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject);
begin
Form2.label1.caption:='hsdfhdsf';//在此出现错误
end;
end.
三个form, form1,form2,form3,其中form1 为主窗口,form2,form3属于
available forms.
在form1中打开form2,在form2 中打开form3,在form3中更改form2中Tlabel
的caption.每次运行到更改语句时出错。请指教我怎样才能达到目的。
代码如下:
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 }
end;
var
Form1: TForm1;
implementation
uses unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Form2:TForm2;
begin
Form2:=TForm2.Create(self);
Form2.Show;
end;
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses unit3;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
var
Form3:tFORM3;
begin
Form3:=TForm3.create(self);
Form3.show;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm3 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses unit2;
{$R *.DFM}
procedure TForm3.Button1Click(Sender: TObject);
begin
Form2.label1.caption:='hsdfhdsf';//在此出现错误
end;
end.